Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataGrid - It is not possible to reorder columns when headerCellRender is used in React (T1139245) #23658

Merged
merged 1 commit into from
Jan 12, 2023
Merged
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
3 changes: 2 additions & 1 deletion js/ui/grid_core/ui.grid_core.column_headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,14 @@ export const columnHeadersModule = {

that.setAria('role', 'presentation', $container);

that._updateContent(that._renderTable({ change }), change);
const deferred = that._updateContent(that._renderTable({ change }), change);

if(that.getRowCount() > 1) {
$container.addClass(MULTI_ROW_HEADER_CLASS);
}

that.callBase.apply(that, arguments);
return deferred;
},

_renderRows: function() {
Expand Down
2 changes: 1 addition & 1 deletion js/ui/grid_core/ui.grid_core.filter_row.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ const ColumnHeadersViewFilterRowExtender = (function() {

_renderCore: function() {
this._filterRangeOverlayInstance = null;
this.callBase.apply(this, arguments);
return this.callBase.apply(this, arguments);
},

_resizeCore: function() {
Expand Down
10 changes: 8 additions & 2 deletions js/ui/grid_core/ui.grid_core.modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,15 @@ const View = ModuleItem.inherit({
$element.toggleClass('dx-hidden', !isVisible);
if(isVisible) {
this.component._optionCache = {};
this._renderCore(options);
const deferred = this._renderCore(options);
this.component._optionCache = undefined;
this.renderCompleted.fire(options);
if(deferred) {
deferred.done(() => {
this.renderCompleted.fire(options);
});
} else {
this.renderCompleted.fire(options);
}
}
},

Expand Down
3 changes: 2 additions & 1 deletion js/ui/grid_core/ui.grid_core.virtual_columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ const VirtualScrollingRowsViewExtender = {

const HeaderViewExtender = {
_renderCore: function() {
this.callBase.apply(this, arguments);
const deferred = this.callBase.apply(this, arguments);

if(this._columnsController.isVirtualMode()) {
this._updateScrollLeftPosition();
}
return deferred;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ QUnit.module('Headers', {
});

QUnit.test('Check correct work getColumnsWidth without columns', function(assert) {
// act
// act
this.columnHeadersView.render($('#container'));
// assert
assert.deepEqual(this.columnHeadersView.getColumnWidths(), [], 'empty column widths');
Expand Down Expand Up @@ -3004,4 +3004,35 @@ QUnit.module('Render templates with renderAsync', {
});
});
});
// T1139245 - DataGrid - It is not possible to reorder columns when headerCellRender is used in React
QUnit.test('The renderCompleted should raise then content has rendered', function(assert) {
const $testElement = $('#container');
const options = {
columns: [{
dataField: 'name',
headerCellTemplate: '#testTemplate'
}],
renderAsync: false,
templatesRenderAsynchronously: true
};

this.setupDataGrid(options);
this._getTemplate = function() {
return {
render: function(options) {
setTimeout(() => {
options.deferred && options.deferred.resolve();
}, 50);
}
};
};
let renderCompletedCall = false;
this.columnHeadersView.renderCompleted.add(() => { renderCompletedCall = true; });

// act
this.columnHeadersView.render($testElement);
assert.ok(!renderCompletedCall, 'renderCompleted isnt fired because template isnt rendered');
this.clock.tick(50);
assert.ok(renderCompletedCall, 'renderCompleted fired after template is rendered');
});
});