Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ export class ExportController extends dataGridCore.ViewController {

private needLoadItemsOnExportingSelectedItems(): boolean {
return this.option('loadItemsOnExportingSelectedItems')
?? this._dataController._dataSource.remoteOperations().filtering;
?? (this._dataController._dataSource?.remoteOperations().filtering ?? false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ const data = (Base: DataControllerBase) => class FocusDataControllerExtender ext
// @ts-expect-error
const deferred = new Deferred();
const isGroupKey = Array.isArray(key);
const group = dataSource.group();

if (isGroupKey) {
if (isGroupKey || !dataSource) {
return deferred.resolve(-1).promise();
}

const group = dataSource.group();

// @ts-expect-error badly typed DataSourceAdapter
if (!dataSource._grouping._updatePagingOptions) {
this._calculateGlobalRowIndexByFlatData(key, null, true)
.done(deferred.resolve)
Expand All @@ -110,12 +112,14 @@ const data = (Base: DataControllerBase) => class FocusDataControllerExtender ext
filter: this._concatWithCombinedFilter(filter),
group,
}).done((data) => {
// @ts-expect-error badly typed DataSourceAdapter
const hasData = isDefined(data) && data.length > 0;

if (this._dataSource !== dataSource || !hasData) {
return deferred.resolve(-1).promise();
}

// @ts-expect-error badly typed DataSourceAdapter
const groupPath = this._getGroupPath(data, group.length);

this._expandGroupByPath(this, groupPath, 0).done(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,19 @@ export const groupingDataControllerExtender = (

private collapseAll(groupIndex: number): void {
const dataSource = this._dataSource;
// @ts-expect-error badly typed DataSourceAdapter
if (dataSource?.collapseAll(groupIndex)) {
dataSource.pageIndex(0);
dataSource.reload();
dataSource?.pageIndex(0);
dataSource?.reload();
}
}

private expandAll(groupIndex: number): void {
const dataSource = this._dataSource;
// @ts-expect-error badly typed DataSourceAdapter
if (dataSource?.expandAll(groupIndex)) {
dataSource.pageIndex(0);
dataSource.reload();
dataSource?.pageIndex(0);
dataSource?.reload();
}
}

Expand Down Expand Up @@ -199,6 +201,7 @@ export const groupingDataControllerExtender = (
}

private isRowExpanded(key: RowKey): boolean {
// @ts-expect-error badly typed DataSourceAdapter
return !!this._dataSource?.isRowExpanded(key);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ const dataSourceAdapterExtender = (Base: ModuleType<DataSourceAdapter>) => class
}
}

protected totalItemsCount() {
public totalItemsCount() {
const totalCount = super.totalItemsCount();

return totalCount > 0 && this._dataSource.group() && this._dataSource.requireTotalCount() ? totalCount + this._grouping.totalCountCorrection() : totalCount;
}

protected itemsCount() {
public itemsCount() {
return this._dataSource.group() ? this._grouping.itemsCount() || 0 : super.itemsCount.apply(this, arguments as any);
}

Expand Down Expand Up @@ -121,7 +121,7 @@ const dataSourceAdapterExtender = (Base: ModuleType<DataSourceAdapter>) => class
return this._grouping.refresh.apply(this._grouping, arguments);
}

protected changeRowExpand(path) {
public changeRowExpand(path) {
const that = this;
const dataSource = that._dataSource;

Expand Down Expand Up @@ -183,7 +183,7 @@ const dataSourceAdapterExtender = (Base: ModuleType<DataSourceAdapter>) => class
return this._grouping.handleDataLoading(options);
}

protected customizeLoadResultHandler(options) {
public customizeLoadResultHandler(options) {
return this._grouping.handleDataLoaded(options, super.customizeLoadResultHandler.bind(this));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const summaryDataControllerExtender = (

public getTotalSummaryValue(summaryItemName?: string | number | null): unknown {
const summaryItemIndex = getSummaryItemIndex(this.option('summary.totalItems'), summaryItemName);
// @ts-expect-error badly typed DataSourceAdapter
const aggregates = this._dataSource.totalAggregates();

if (aggregates.length && summaryItemIndex > -1) {
Expand Down Expand Up @@ -293,6 +294,7 @@ export const summaryDataControllerExtender = (
this._footerItems = [];

if (dataSource && summaryTotalItems?.length) {
// @ts-expect-error badly typed DataSourceAdapter
const totalAggregates = dataSource.totalAggregates();
const summaryCells = this._getSummaryCells(summaryTotalItems, totalAggregates);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import type {
CallbackFlags,
DataChange,
DataFilter,
DataSourceAdapterLike,
GeneratedItem,
ItemChange,
ItemProcessingOptions,
Expand Down Expand Up @@ -66,8 +65,7 @@ import {
import { generateRowValues } from './utils/row_values';

export class DataController extends modules.Controller {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public _dataSource?: any;
public _dataSource?: DataSourceAdapter | null;

protected isSharedDataSource?: boolean;

Expand Down Expand Up @@ -188,7 +186,8 @@ export class DataController extends modules.Controller {
* @extended: virtual_scrolling
*/
protected _getPagingOptionValue(optionName: PagingOptionName): number {
return this._dataSource[optionName]() as number;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return this._dataSource![optionName]() as number;
}

protected callbackNames(): string[] {
Expand Down Expand Up @@ -333,8 +332,7 @@ export class DataController extends modules.Controller {
}

public getDataSource(): DataSource | null | undefined {
const adapter: DataSourceAdapterLike | null | undefined = this._dataSource;
return adapter ? adapter._dataSource : null;
return this._dataSource?._dataSource;
}
Comment on lines 334 to 336

@Tucchhaa Tucchhaa Aug 31, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  public getDataSource(): DataSource | undefined {
    return this._dataSource?._dataSource;
  }

then make DataSourceAdapter._dataSource to be public and delete DataSourceAdapterLike type as it is not used anywhere else


public getCombinedFilter(returnDataField?: boolean): DataFilter {
Expand Down Expand Up @@ -418,6 +416,9 @@ export class DataController extends modules.Controller {
private readonly customizeStoreLoadOptionsHandler = (e: LoadOperation): void => {
const columnsController = this._columnsController;
const dataSource = this._dataSource;
if (!dataSource) {
return;
}
const { storeLoadOptions } = e;

if (e.isCustomLoading && !storeLoadOptions.isLoadingAll) {
Expand Down Expand Up @@ -726,7 +727,7 @@ export class DataController extends modules.Controller {
dataSource.load().done((...args: unknown[]) => {
this._isPaging = false;
result.resolve(...args);
}).fail(result.reject);
}).fail((...args: unknown[]) => { result.reject(...args); });
} else {
result.resolve();
}
Expand Down Expand Up @@ -1478,7 +1479,7 @@ export class DataController extends modules.Controller {
}

public pageCount(): number {
return this._dataSource ? this._dataSource.pageCount() as number : 1;
return this._dataSource ? this._dataSource.pageCount() : 1;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -1525,15 +1526,15 @@ export class DataController extends modules.Controller {
requireTotalCount: false,
};
dataSource.load(loadOptions)
.done((loadedItems: RawItemData[], extra: LoadOperation['extra']): void => {
.done((loadedItems: unknown, extra: unknown): void => {
const items = this._processItems(
this._beforeProcessItems(loadedItems),
this._beforeProcessItems(loadedItems as RawItemData[]),
{ changeType: 'loadingAll' },
);
// @ts-expect-error DataGrid-only summary leaks into grid_core
d.resolve(items, extra?.summary);
d.resolve(items, (extra as LoadOperation['extra'])?.summary);
})
.fail(d.reject);
.fail(d.reject as (...args: unknown[]) => void);
Comment on lines 1528 to +1537

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can keep these as for now, since this method will be refactored in the PR with CustomLoadPipeline:
https://github.com/DevExpress/DevExtreme/pull/34985/changes#diff-2fcaa9c5b931f7dac59f24898189fb29e1e4376b3f81f7ae612f670f6f195d04R1498-R1511

} else {
d.reject();
}
Expand Down Expand Up @@ -1628,7 +1629,8 @@ export class DataController extends modules.Controller {
this._skipProcessingPagingChange = false;
}

const pageIndex = dataSource.pageIndex();
// @ts-expect-error badly typed DataSourceAdapter
const pageIndex: number = dataSource.pageIndex();
this._isPaging = optionName === 'pageIndex';

const loadResult: DeferredObj<unknown> = dataSource[optionName === 'pageIndex' ? 'load' : 'reload']();
Expand Down Expand Up @@ -1779,19 +1781,20 @@ export class DataController extends modules.Controller {
}

public push(...args: unknown[]): unknown {
// @ts-expect-error badly typed DataSourceAdapter
return this._dataSource?.push(...args);
}
Comment thread
bit-byte0 marked this conversation as resolved.

private itemsCount(): number {
return (this._dataSource ? this._dataSource.itemsCount() : 0) as number;
return (this._dataSource ? this._dataSource.itemsCount() : 0);
}

public totalItemsCount(): number {
return (this._dataSource ? this._dataSource.totalItemsCount() : 0) as number;
return (this._dataSource ? this._dataSource.totalItemsCount() : 0);
}

public hasKnownLastPage(): boolean {
return (this._dataSource ? this._dataSource.hasKnownLastPage() : true) as boolean;
return (this._dataSource ? this._dataSource.hasKnownLastPage() : true);
}

/**
Expand All @@ -1802,7 +1805,7 @@ export class DataController extends modules.Controller {
}

public totalCount(): number {
return (this._dataSource ? this._dataSource.totalCount() : 0) as number;
return (this._dataSource ? this._dataSource.totalCount() : 0);
}

public hasLoadOperation(): boolean {
Expand Down
Loading
Loading