Skip to content

Commit 273976e

Browse files
authored
DataGrid - AI Column: Support headerCellTemplate/cellTemplate (DevExpress#31178)
Co-authored-by: Alyar <>
1 parent f73ad83 commit 273976e

File tree

3 files changed

+273
-74
lines changed

3 files changed

+273
-74
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import DataGrid from '@js/ui/data_grid';
2+
3+
import { GridCoreModel } from '../../../../grid_core/__tests__/__mock__/model/grid_core';
4+
5+
export class DataGridModel extends GridCoreModel<DataGrid> {
6+
public getInstance(): DataGrid {
7+
return DataGrid.getInstance(this.root) as DataGrid;
8+
}
9+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2+
/* eslint-disable @typescript-eslint/no-explicit-any */
3+
import type { GridBase } from '@js/common/grids';
4+
5+
const CLASSES = {
6+
headerRow: 'dx-header-row',
7+
dataRow: 'dx-data-row',
8+
};
9+
10+
export abstract class GridCoreModel<TInstance extends GridBase = GridBase> {
11+
constructor(protected readonly root: HTMLElement) {}
12+
13+
public getHeaderCell(columnIndex: number): HTMLElement {
14+
return this.root.querySelectorAll(`.${CLASSES.headerRow} > td`)[columnIndex] as HTMLElement;
15+
}
16+
17+
public getCellElement(rowIndex: number, columnIndex: number): HTMLElement {
18+
return this.root.querySelectorAll(`.${CLASSES.dataRow}`)[rowIndex]?.querySelectorAll('td')[columnIndex] as HTMLElement;
19+
}
20+
21+
public apiColumnOption(id: string, name?: string, value?: any): any {
22+
switch (arguments.length) {
23+
case 1:
24+
return this.getInstance().columnOption(id);
25+
case 2:
26+
return this.getInstance().columnOption(id, name);
27+
default:
28+
this.getInstance().columnOption(id, name as string, value);
29+
return undefined;
30+
}
31+
}
32+
33+
public abstract getInstance(): TInstance;
34+
}

0 commit comments

Comments
 (0)