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 @@ -20,8 +20,11 @@ import { create } from '@js/core/utils/queue';
import {
isBoolean, isDefined, isEmptyObject, isNumeric, isObject, isString,
} from '@js/core/utils/type';
import type { StoreChange } from '@js/data/store';
import commonUtils from '@ts/core/utils/m_common';

import type { ChangedEvent, LoadOperation } from './types';

export const DataSource = Class.inherit({
ctor(options) {
// @ts-expect-error
Expand Down Expand Up @@ -332,9 +335,9 @@ export const DataSource = Class.inherit({
});
},

_fireChanged(args) {
_fireChanged(e?: ChangedEvent) {
const date = new Date();
this._eventsStrategy.fireEvent('changed', args);
this._eventsStrategy.fireEvent('changed', [e]);
// @ts-expect-error
this._changedTime = new Date() - date;
},
Expand Down Expand Up @@ -412,7 +415,7 @@ export const DataSource = Class.inherit({
this._scheduleFailCallbacks(d);
this._scheduleChangedCallbacks(d);

const loadOperation = this._createLoadOperation(d);
const loadOperation: LoadOperation = this._createLoadOperation(d);

this._eventsStrategy.fireEvent('customizeStoreLoadOptions', [loadOperation]);

Expand All @@ -430,7 +433,7 @@ export const DataSource = Class.inherit({
});
},

_onPush(changes) {
_onPush(changes: StoreChange[]) {
if (this._reshapeOnPush) {
this.load();
} else {
Expand Down Expand Up @@ -466,11 +469,11 @@ export const DataSource = Class.inherit({
groupCount: groupLevel,
useInsertIndex: true,
});
this._fireChanged([{ changes }]);
this._fireChanged({ changes });
}
},

_createLoadOperation(deferred) {
_createLoadOperation(deferred): LoadOperation {
const operationId = this._operationManager.add(deferred);
const storeLoadOptions = this._createStoreLoadOptions();

Expand Down
22 changes: 22 additions & 0 deletions packages/devextreme/js/__internal/data/data_source/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { DataSourceOptionsStub } from '@js/data/data_source';
import type { StoreChange } from '@js/data/store';

export interface StoreLoadOptions extends Pick<
DataSourceOptionsStub,
'sort' | 'filter' | 'langParams' | 'select' | 'group'
| 'requireTotalCount' | 'searchOperation' | 'searchValue' | 'searchExpr'
> {
skip?: number;
take?: number;
userData?: unknown;
}

export interface LoadOperation {
operationId: number;
storeLoadOptions: StoreLoadOptions;
delay?: number;
}

export interface ChangedEvent {
changes?: StoreChange[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -817,11 +817,15 @@ const data = (Base: ModuleType<DataController>) => class SummaryDataControllerEx
return sortByGroups;
}

protected _createDataSourceAdapterCore(dataSource, remoteOperations) {
const that = this;
const dataSourceAdapter = super._createDataSourceAdapterCore(dataSource, remoteOperations);

dataSourceAdapter.summaryGetter((currentRemoteOperations) => that._getSummaryOptions(currentRemoteOperations || remoteOperations));
protected _createDataSourceAdapter(dataSource) {
const dataSourceAdapter = super._createDataSourceAdapter(dataSource);

dataSourceAdapter.summaryGetter((currentRemoteOperations) => {
const result = this._getSummaryOptions(
currentRemoteOperations ?? dataSourceAdapter.remoteOperations(),
);
return result;
});

return dataSourceAdapter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import type { Column } from '@ts/grids/grid_core/columns_controller/types';

import type { ColumnsController } from '../../columns_controller/m_columns_controller';
import type { DataController } from '../../data_controller/data_controller';
import type { HandleDataChangedArguments, UserData } from '../../data_controller/types';
import type { UserData } from '../../data_controller/types';
import type { ChangedEvent } from '../../data_source_adapter/types';
import { Controller } from '../../m_modules';
import type { RowKey } from '../../m_types';
import gridCoreUtils from '../../m_utils';
Expand All @@ -20,7 +21,7 @@ export class AIColumnController extends Controller {

private aiColumnIntegrationController!: AIColumnIntegrationController;

private dataSourceChangedHandler!: (e?: HandleDataChangedArguments) => void;
private dataSourceChangedHandler!: (e?: ChangedEvent) => void;

private storeUpdatedHandler!: (key: RowKey) => void;

Expand Down Expand Up @@ -150,6 +151,7 @@ export class AIColumnController extends Controller {

private updateAICells(): void {
this.dataController.updateItems({
changeType: 'refresh',
repaintChangesOnly: this.option('repaintChangesOnly'),
});
}
Expand Down Expand Up @@ -188,8 +190,8 @@ export class AIColumnController extends Controller {
}
}

private handleDataSourceChanged(args?: HandleDataChangedArguments): void {
if (args?.changeType === 'loadError') {
private handleDataSourceChanged(e?: ChangedEvent): void {
if (e?.changeType === 'loadError') {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DataSource } from '@js/common/data/data_source/data_source';
import { normalizeDataSourceOptions } from '@js/common/data/data_source/utils';
import config from '@js/core/config';
import $ from '@js/core/renderer';
import type { Callback } from '@js/core/utils/callbacks';
import Callbacks from '@js/core/utils/callbacks';
import { compileGetter } from '@js/core/utils/data';
import { Deferred, when } from '@js/core/utils/deferred';
Expand All @@ -19,7 +20,7 @@ import Store from '@js/data/abstract_store';
import filterUtils from '@js/ui/shared/filtering';
import errors from '@js/ui/widget/ui.errors';
import inflector from '@ts/core/utils/m_inflector';
import type { Column, FilterField } from '@ts/grids/grid_core/columns_controller/types';
import type { Column, ColumnsChanges, FilterField } from '@ts/grids/grid_core/columns_controller/types';
import type { DataController } from '@ts/grids/grid_core/data_controller/data_controller';
import type { FocusController } from '@ts/grids/grid_core/focus/m_focus';
import type { StateStoringController } from '@ts/grids/grid_core/state_storing/m_state_storing_core';
Expand Down Expand Up @@ -126,11 +127,11 @@ export class ColumnsController extends modules.Controller {

private __sortingUpdated: any;

public columnsChanged: any;
public columnsChanged!: Callback<[ColumnsChanges]>;

public aiColumnOptionChanged: any;

public _columnChanges: any;
public _columnChanges?: ColumnsChanges;

protected _dataController!: DataController;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ import {
VIRTUAL_COMMAND_COLUMN_NAME,
} from './const';
import type { ColumnsController } from './m_columns_controller';
import type { Column, ColumnIndex, DropLocationNames } from './types';
import type {
Column, ColumnIndex, ColumnsChanges, DropLocationNames,
} from './types';

const warnFixedInChildColumnsOnce = (controller: ColumnsController, childColumns: any[]): void => {
if (controller?._isWarnedAboutUnsupportedProperties) return;
Expand Down Expand Up @@ -610,16 +612,19 @@ export function assignColumns(that, columns) {
that.updateColumnDataTypes();
}

export const updateColumnChanges = function (that: ColumnsController, changeType, optionName?, columnIndex?) {
const columnChanges = that._columnChanges || {
export const updateColumnChanges = (
that: ColumnsController,
changeType: Exclude<keyof ColumnsChanges['changeTypes'], 'length'>,
optionName?: string,
columnIndex?: number,
): void => {
const columnChanges: ColumnsChanges = that._columnChanges ?? {
optionNames: { length: 0 },
changeTypes: { length: 0 },
columnIndex, // TODO replace columnIndex -> columnIndices
};

optionName = optionName || 'all';

optionName = optionName.split('.')[0];
const normalizedOptionName = (optionName ?? 'all').split('.')[0] as keyof Column | 'all';

const { changeTypes } = columnChanges;

Expand All @@ -630,8 +635,8 @@ export const updateColumnChanges = function (that: ColumnsController, changeType

const { optionNames } = columnChanges;

if (optionName && !optionNames[optionName]) {
optionNames[optionName] = true;
if (normalizedOptionName && !optionNames[normalizedOptionName]) {
optionNames[normalizedOptionName] = true;
optionNames.length++;
}
if (columnIndex === undefined || columnIndex !== columnChanges.columnIndex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,24 @@ export interface Column extends ColumnBase {
rowspan?: number;
colspan?: number;
}

export interface ColumnsChanges {
changeTypes: {
sorting?: boolean;
grouping?: boolean;
groupExpanding?: boolean;
columns?: boolean;
filtering?: boolean;
event?: unknown;
virtualColumnsScrolling?: boolean;
length: number;
};
optionNames: {
[name in keyof Column]?: boolean;
} & {
all?: boolean;
length: number;
};
columnIndex?: number;
columnIndices?: number[];
}
Loading
Loading