Skip to content

Commit

Permalink
DataGrid: Fix disabled state for export button when using the `toolba…
Browse files Browse the repository at this point in the history
…r|items|disabled` option (T1189621) (#25640)

Co-authored-by: Alyar <>
  • Loading branch information
Alyar666 authored Sep 22, 2023
1 parent 3c673d3 commit ab93616
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ const members = {
}
},

_isDisabledDefinedByUser(name: string): boolean {
const userItems = this.option('toolbar')?.items;
const userItem = userItems?.find((item) => item?.name === name);

return isDefined(userItem?.disabled);
},

init() {
this.callBase();
this.createAction('onToolbarPreparing', { excludeValidators: ['disabled', 'readOnly'] });
Expand All @@ -138,8 +145,9 @@ const members = {

setToolbarItemDisabled(name, disabled: boolean): void {
const toolbar = this._toolbar;
const isDefinedByUser = this._isDisabledDefinedByUser(name);

if (!toolbar) {
if (!toolbar || isDefinedByUser) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2807,5 +2807,30 @@ QUnit.module('Real dataGrid ExportController tests', {
}]
], 'PrepareItems is correct with custom Array prototype method');
});

// T1189621
QUnit.test('The export button should be disabled using the `toolbar|items|disabled` option ', function(assert) {
// arrange, act
const $container = $('#container');

createDataGrid({
dataSource: [{ id: 0, field: 1 }],
export: {
enabled: true,
},
toolbar: {
items: [{
name: 'exportButton',
disabled: true
}]
},
});

this.clock.tick(50);

// assert
const $exportButton = $container.find('.dx-datagrid-export-button');
assert.ok($exportButton.closest('.dx-toolbar-item').hasClass('dx-state-disabled'), 'export button is disabled');
});
});

0 comments on commit ab93616

Please sign in to comment.