Skip to content
Draft
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 @@ -88,7 +88,7 @@ const data = (Base: DataControllerBase) => class FocusDataControllerExtender ext
}

private _calculateGlobalRowIndexByGroupedData(key) {
const dataSource = this._dataSource;
const dataSource = this._dataSource as any;
const filter = this._generateFilterByKey(key);
// @ts-expect-error
const deferred = new Deferred();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,17 @@ export const groupingDataControllerExtender = (
}

private collapseAll(groupIndex: number): void {
const dataSource = this._dataSource;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const dataSource = this._dataSource as any;
if (dataSource?.collapseAll(groupIndex)) {
dataSource.pageIndex(0);
dataSource.reload();
}
}

private expandAll(groupIndex: number): void {
const dataSource = this._dataSource;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const dataSource = this._dataSource as any;
if (dataSource?.expandAll(groupIndex)) {
dataSource.pageIndex(0);
dataSource.reload();
Expand All @@ -182,7 +184,8 @@ export const groupingDataControllerExtender = (
}

protected changeRowExpandCore(key: RowKey): DeferredObj<unknown> {
const dataSource = this._dataSource;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const dataSource = this._dataSource as any;

const d = Deferred();
if (!dataSource) {
Expand All @@ -199,7 +202,8 @@ export const groupingDataControllerExtender = (
}

private isRowExpanded(key: RowKey): boolean {
return !!this._dataSource?.isRowExpanded(key);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return !!(this._dataSource as any)?.isRowExpanded(key);
}

private expandRow(key: RowKey): DeferredObj<unknown> {
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,7 +43,8 @@ export const summaryDataControllerExtender = (

public getTotalSummaryValue(summaryItemName?: string | number | null): unknown {
const summaryItemIndex = getSummaryItemIndex(this.option('summary.totalItems'), summaryItemName);
const aggregates = this._dataSource.totalAggregates();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const aggregates = (this._dataSource as any).totalAggregates();

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

if (dataSource && summaryTotalItems?.length) {
const totalAggregates = dataSource.totalAggregates();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const totalAggregates = (dataSource as any).totalAggregates();
const summaryCells = this._getSummaryCells(summaryTotalItems, totalAggregates);

if (change?.repaintChangesOnly && oldSummaryCells) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,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 +187,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,7 +333,7 @@ export class DataController extends modules.Controller {
}

public getDataSource(): DataSource | null | undefined {
const adapter: DataSourceAdapterLike | null | undefined = this._dataSource;
const adapter = this._dataSource as unknown as DataSourceAdapterLike | null | undefined;
return adapter ? adapter._dataSource : null;
}

Expand Down Expand Up @@ -418,6 +418,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 @@ -590,7 +593,7 @@ export class DataController extends modules.Controller {
errors.log('W1005', this.component.NAME);
this._applyFilter();
} else {
this._currentOperationTypes = dataSource.operationTypes();
this._currentOperationTypes = dataSource.operationTypes() ?? null;

const change: DataChange = isDefined(e)
? {
Expand Down Expand Up @@ -726,7 +729,7 @@ export class DataController extends modules.Controller {
dataSource.load().done((...args: unknown[]) => {
this._isPaging = false;
result.resolve(...args);
}).fail(result.reject);
}).fail(result.reject as (...args: unknown[]) => void);
} else {
result.resolve();
}
Expand Down Expand Up @@ -1478,7 +1481,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 +1528,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);
} else {
d.reject();
}
Expand Down Expand Up @@ -1628,10 +1631,12 @@ export class DataController extends modules.Controller {
this._skipProcessingPagingChange = false;
}

const pageIndex = dataSource.pageIndex();
const pageIndex = dataSource.pageIndex() as unknown as number;
this._isPaging = optionName === 'pageIndex';

const loadResult: DeferredObj<unknown> = dataSource[optionName === 'pageIndex' ? 'load' : 'reload']();
const loadResult: DeferredObj<unknown> = (
dataSource[optionName === 'pageIndex' ? 'load' : 'reload'] as () => DeferredObj<unknown>
)();

return loadResult.done(() => {
this._isPaging = false;
Expand Down Expand Up @@ -1779,19 +1784,19 @@ export class DataController extends modules.Controller {
}

public push(...args: unknown[]): unknown {
return this._dataSource?.push(...args);
return (this._dataSource?.push as ((...a: unknown[]) => unknown) | undefined)?.(...args);
}

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 +1807,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