File tree Expand file tree Collapse file tree 3 files changed +273
-74
lines changed
packages/devextreme/js/__internal/grids
data_grid/__tests__/__mock__/model Expand file tree Collapse file tree 3 files changed +273
-74
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments