1
1
import 'igniteui-webcomponents-grids/grids/combined' ;
2
- import { ComponentRenderer , WebGridDescriptionModule , WebPaginatorDescriptionModule } from 'igniteui-webcomponents-core' ;
3
- import { IgcGridComponent } from 'igniteui-webcomponents-grids/grids' ;
2
+ import { ComponentRenderer , WebGridDescriptionModule , WebPaginatorDescriptionModule , WebInputDescriptionModule } from 'igniteui-webcomponents-core' ;
3
+ import { IgcGridComponent , IgcColumnComponent } from 'igniteui-webcomponents-grids/grids' ;
4
4
import NwindData from './NwindData.json' ;
5
+ import { IgcCellTemplateContext } from 'igniteui-webcomponents-grids/grids' ;
6
+ import { html } from 'lit-html' ;
5
7
6
8
import "igniteui-webcomponents-grids/grids/themes/light/bootstrap.css" ;
9
+ import 'igniteui-webcomponents/themes/light/bootstrap.css' ;
10
+ import { defineAllComponents } from 'igniteui-webcomponents' ;
11
+ defineAllComponents ( ) ;
7
12
8
13
import "./index.css" ;
9
14
10
15
export class Sample {
11
16
12
17
private grid : IgcGridComponent
18
+ private column1 : IgcColumnComponent
13
19
private _bind : ( ) => void ;
14
20
15
21
constructor ( ) {
16
22
var grid = this . grid = document . getElementById ( 'grid' ) as IgcGridComponent ;
23
+ this . webGridOnEditEnter = this . webGridOnEditEnter . bind ( this ) ;
24
+ var column1 = this . column1 = document . getElementById ( 'column1' ) as IgcColumnComponent ;
17
25
18
26
this . _bind = ( ) => {
19
27
grid . data = this . nwindData ;
28
+ grid . addEventListener ( "cellEditEnter" , this . webGridOnEditEnter ) ;
29
+ column1 . inlineEditorTemplate = this . webGridNumericColEditCellTemplate ;
20
30
}
21
31
this . _bind ( ) ;
22
32
@@ -34,10 +44,45 @@ export class Sample {
34
44
var context = this . _componentRenderer . context ;
35
45
WebGridDescriptionModule . register ( context ) ;
36
46
WebPaginatorDescriptionModule . register ( context ) ;
47
+ WebInputDescriptionModule . register ( context ) ;
37
48
}
38
49
return this . _componentRenderer ;
39
50
}
40
51
52
+ public webGridOnEditEnter ( args : any ) : void {
53
+ const column = args . detail . column ;
54
+ if ( column . field === 'ReorderLevel' ) {
55
+ setTimeout ( ( ) => {
56
+ const rowId = args . detail . cellID . rowID ;
57
+ const columnId = args . detail . cellID . columnID ;
58
+ const inputTemplateId = `edit-cell-${ rowId } -${ columnId } ` ;
59
+ const element = document . getElementById ( inputTemplateId ) ;
60
+ element ?. focus ( ) ;
61
+ } ) ;
62
+ }
63
+ }
64
+
65
+ public webGridNumericColEditCellTemplate = ( ctx : IgcCellTemplateContext ) => {
66
+ const cell = ctx . cell ;
67
+ const columnName = cell . column . field ;
68
+ const cellValue = cell . row . data [ columnName ] ;
69
+ const rowId = cell . id . rowID ;
70
+ const columnId = cell . id . columnID ;
71
+ const inputTemplateId = `edit-cell-${ rowId } -${ columnId } ` ;
72
+
73
+ return html `
74
+ < igc-input
75
+ type ="number "
76
+ id ="${ inputTemplateId } "
77
+ name ="${ cell . id . rowID } "
78
+ style ="width: 100%; "
79
+ value ="${ cellValue } "
80
+ @igcChange =${ ( e : any ) => {
81
+ cell . editValue = e . detail ;
82
+ } } >
83
+ </ igc-input > ` ;
84
+ }
85
+
41
86
}
42
87
43
88
new Sample ( ) ;
0 commit comments