Skip to content

Commit 21190d8

Browse files
authored
DataGrid - AI Column: Column reordering does not work if allowColumnReordering and columnFixing.enabled turned on (#31836)
1 parent 8e65674 commit 21190d8

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

e2e/testcafe-devextreme/tests/dataGrid/common/aiColumn/columnReordering.functional.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,42 @@ test('Column reordering should not work when it has allowReordering set to false
115115
{ dataField: 'value', caption: 'Value' },
116116
],
117117
}));
118+
119+
test('Column reordering should work when allowColumnReordering is true and columnFixing.enabled is true', async (t) => {
120+
// arrange
121+
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);
122+
const headerRow = dataGrid.getHeaders().getHeaderRow(0);
123+
124+
await t.expect(dataGrid.isReady()).ok();
125+
126+
// assert
127+
await t.expect(await headerRow.getHeaderTexts()).eql(['AI Column', 'ID', 'Name', 'Value']);
128+
129+
// act
130+
await t.drag(headerRow.getHeaderCell(0).element, 150, 0);
131+
132+
// assert
133+
await t.expect(await headerRow.getHeaderTexts()).eql(['ID', 'AI Column', 'Name', 'Value']);
134+
}).before(async () => createWidget('dxDataGrid', {
135+
dataSource: [
136+
{ id: 1, name: 'Name 1', value: 10 },
137+
{ id: 2, name: 'Name 2', value: 20 },
138+
{ id: 3, name: 'Name 3', value: 30 },
139+
],
140+
keyExpr: 'id',
141+
allowColumnReordering: true,
142+
columnFixing: {
143+
enabled: true,
144+
},
145+
columnWidth: 100,
146+
columns: [
147+
{
148+
type: 'ai',
149+
caption: 'AI Column',
150+
name: 'myAiColumn',
151+
},
152+
{ dataField: 'id', caption: 'ID' },
153+
{ dataField: 'name', caption: 'Name' },
154+
{ dataField: 'value', caption: 'Value' },
155+
],
156+
}));

packages/devextreme/js/__internal/grids/grid_core/columns_controller/m_columns_controller_utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,15 @@ export const mergeColumns = (that: ColumnsController, columns, commandColumns, n
915915
return result;
916916
};
917917

918-
export const isColumnFixed = (that: ColumnsController, column) => (isDefined(column.fixed) || !column.type ? column.fixed && column.fixedPosition !== StickyPosition.Sticky : that._isColumnFixing());
918+
export const isColumnFixed = (that: ColumnsController, column) => {
919+
const isFixedCommandColumn = column.type && column.type !== AI_COLUMN_NAME;
920+
921+
if (!isFixedCommandColumn) {
922+
return column.fixed && column.fixedPosition !== StickyPosition.Sticky;
923+
}
924+
925+
return that._isColumnFixing();
926+
};
919927

920928
export const convertOwnerBandToColumnReference = (columns) => {
921929
columns.forEach((column) => {

0 commit comments

Comments
 (0)