Skip to content

Commit 1cec22c

Browse files
authored
DataGrid - AI Column: Support width/minWidth (#31107)
Co-authored-by: Alyar <>
1 parent 18e6611 commit 1cec22c

File tree

2 files changed

+104
-3
lines changed

2 files changed

+104
-3
lines changed

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

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fixture`Ai Column.ColumnResizing`
88
const DATA_GRID_SELECTOR = '#container';
99

1010
(['nextColumn', 'widget'] as const).forEach((columnResizingMode) => {
11-
test(`Column resizing should work when allowColumnResizing is true and columnResizingMode = ${columnResizingMode}`, async (t) => {
11+
test(`Column resizing should work when allowColumnResizing is true (columnResizingMode = ${columnResizingMode})`, async (t) => {
1212
// arrange
1313
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);
1414
const dataCell = dataGrid.getDataCell(0, 0);
@@ -47,7 +47,7 @@ const DATA_GRID_SELECTOR = '#container';
4747
],
4848
}));
4949

50-
test(`Column resizing should work when allowResizing is true and columnResizingMode = ${columnResizingMode}`, async (t) => {
50+
test(`Column resizing should work when allowResizing is true (columnResizingMode = ${columnResizingMode})`, async (t) => {
5151
// arrange
5252
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);
5353
const dataCell = dataGrid.getDataCell(0, 0);
@@ -92,7 +92,7 @@ const DATA_GRID_SELECTOR = '#container';
9292
],
9393
}));
9494

95-
test(`Column resizing should not work when allowResizing is false and columnResizingMode = ${columnResizingMode}`, async (t) => {
95+
test(`Column resizing should not work when allowResizing is false (columnResizingMode = ${columnResizingMode})`, async (t) => {
9696
// arrange
9797
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);
9898
const dataCell = dataGrid.getDataCell(0, 0);
@@ -131,4 +131,44 @@ const DATA_GRID_SELECTOR = '#container';
131131
{ dataField: 'value', caption: 'Value' },
132132
],
133133
}));
134+
135+
test(`The column width should not be less than its min width when column resizing (columnResizingMode = ${columnResizingMode})`, async (t) => {
136+
// arrange
137+
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);
138+
const dataCell = dataGrid.getDataCell(0, 0);
139+
140+
await t.expect(dataGrid.isReady()).ok();
141+
142+
// assert
143+
await t
144+
.expect(dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(0).element.textContent)
145+
.eql('AI Column')
146+
.expect(dataCell.element.clientWidth)
147+
.eql(100);
148+
149+
// act
150+
await dataGrid.resizeHeader(1, -50);
151+
152+
// assert
153+
await t.expect(dataCell.element.clientWidth).eql(75);
154+
}).before(async () => createWidget('dxDataGrid', {
155+
dataSource: [
156+
{ id: 1, name: 'Name 1', value: 10 },
157+
{ id: 2, name: 'Name 2', value: 20 },
158+
{ id: 3, name: 'Name 3', value: 30 },
159+
],
160+
allowColumnResizing: true,
161+
columnResizingMode,
162+
columnWidth: 100,
163+
columns: [
164+
{
165+
type: 'ai',
166+
caption: 'AI Column',
167+
minWidth: 75,
168+
},
169+
{ dataField: 'id', caption: 'ID' },
170+
{ dataField: 'name', caption: 'Name' },
171+
{ dataField: 'value', caption: 'Value' },
172+
],
173+
}));
134174
});
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import DataGrid from 'devextreme-testcafe-models/dataGrid';
2+
import url from '../../../../helpers/getPageUrl';
3+
import { createWidget } from '../../../../helpers/createWidget';
4+
5+
fixture`Ai Column.Common`
6+
.page(url(__dirname, '../../../container.html'));
7+
8+
const DATA_GRID_SELECTOR = '#container';
9+
10+
test('The AI column with a given width', async (t) => {
11+
// arrange, act
12+
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);
13+
14+
await t.expect(dataGrid.isReady()).ok();
15+
16+
// assert
17+
await t.expect(dataGrid.getDataCell(0, 3).element.clientWidth).eql(175);
18+
}).before(async () => createWidget('dxDataGrid', {
19+
dataSource: [
20+
{ id: 1, name: 'Name 1', value: 10 },
21+
{ id: 2, name: 'Name 2', value: 20 },
22+
{ id: 3, name: 'Name 3', value: 30 },
23+
],
24+
columns: [
25+
{ dataField: 'id', caption: 'ID' },
26+
{ dataField: 'name', caption: 'Name' },
27+
{ dataField: 'value', caption: 'Value' },
28+
{
29+
type: 'ai',
30+
caption: 'AI Column',
31+
width: 175,
32+
},
33+
],
34+
}));
35+
36+
test('The AI column with a given min-width', async (t) => {
37+
// arrange, act
38+
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);
39+
40+
await t.expect(dataGrid.isReady()).ok();
41+
42+
// assert
43+
await t.expect(dataGrid.getDataCell(0, 3).element.clientWidth).eql(175);
44+
}).before(async () => createWidget('dxDataGrid', {
45+
dataSource: [
46+
{ id: 1, name: 'Name 1', value: 10 },
47+
{ id: 2, name: 'Name 2', value: 20 },
48+
{ id: 3, name: 'Name 3', value: 30 },
49+
],
50+
width: 300,
51+
columns: [
52+
{ dataField: 'id', caption: 'ID' },
53+
{ dataField: 'name', caption: 'Name' },
54+
{ dataField: 'value', caption: 'Value', width: 100 },
55+
{
56+
type: 'ai',
57+
caption: 'AI Column',
58+
minWidth: 175,
59+
},
60+
],
61+
}));

0 commit comments

Comments
 (0)