Skip to content

Commit

Permalink
DataGrid - "W1024 - The client-side export is enabled" warning occurs…
Browse files Browse the repository at this point in the history
… when the exporting feature is used in Angular (T1188932) (#25665)
  • Loading branch information
pomahtri authored Sep 27, 2023
1 parent 3db06ad commit ed5daf4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
22 changes: 14 additions & 8 deletions js/__internal/grids/data_grid/export/m_export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,11 +608,16 @@ export class ExportController extends dataGridCore.ViewController {
return headersView && headersView.isVisible() ? headersView.getColumnWidths() : rowsView.getColumnWidths();
}

init() {
if (this.option('export.enabled') && !isDefined(this.option('onExporting'))) {
private throwWarningIfNoOnExportingEvent(): void {
const hasOnExporting = (this.component as any).hasActionSubscription?.('onExporting');

if (this.option('export.enabled') && !hasOnExporting) {
errors.log('W1024');
}
}

init() {
this.throwWarningIfNoOnExportingEvent();
this._columnsController = this.getController('columns');
this._rowsView = this.getView('rowsView');
this._headersView = this.getView('columnHeadersView' as any);
Expand Down Expand Up @@ -666,6 +671,13 @@ export class ExportController extends dataGridCore.ViewController {
}
}

optionChanged(args) {
super.optionChanged(args);
if (args.name === 'export') {
this.throwWarningIfNoOnExportingEvent();
}
}

needLoadItemsOnExportingSelectedItems(): boolean {
return this.option('loadItemsOnExportingSelectedItems')
?? this.getController('data')._dataSource.remoteOperations().filtering;
Expand Down Expand Up @@ -838,12 +850,6 @@ dataGridCore.registerModule('export', {
if (args.name === 'export') {
args.handled = true;
this._invalidate();

if (args.fullName === 'export.enabled') {
if (args.value && !isDefined(this.option('onExporting'))) {
errors.log('W1024');
}
}
}
},

Expand Down
29 changes: 17 additions & 12 deletions testing/testcafe/tests/dataGrid/export/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,22 @@ test('Warning should be thrown in console if exporting is enabled, but onExporti
});
});

test('Warning should be thrown in console if exporting is enabled dynamically, but onExporting is not specified', async (t) => {
const dataGrid = new DataGrid(GRID_CONTAINER);

await dataGrid.option('export.enabled', true);

const consoleMessages = await t.getBrowserConsoleMessages();
const isWarningExist = !!consoleMessages?.warn.find((message) => message.startsWith('W1024'));

await t.expect(isWarningExist).ok();
}).before(async () => {
await createWidget('dxDataGrid', {
dataSource: [],
([
['export', { enabled: true }],
['export.enabled', true],
] as const).forEach(([option, value]) => {
test(`Warning should be thrown in console if exporting is enabled dynamically with '${option}' option, but onExporting is not specified`, async (t) => {
const dataGrid = new DataGrid(GRID_CONTAINER);

await dataGrid.option(option, value);

const consoleMessages = await t.getBrowserConsoleMessages();
const isWarningExist = !!consoleMessages?.warn.find((message) => message.startsWith('W1024'));

await t.expect(isWarningExist).ok();
}).before(async () => {
await createWidget('dxDataGrid', {
dataSource: [],
});
});
});

0 comments on commit ed5daf4

Please sign in to comment.