11import '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' ;
44import NwindData from './NwindData.json' ;
5+ import { IgcCellTemplateContext } from 'igniteui-webcomponents-grids/grids' ;
6+ import { html } from 'lit-html' ;
57
68import "igniteui-webcomponents-grids/grids/themes/light/bootstrap.css" ;
9+ import 'igniteui-webcomponents/themes/light/bootstrap.css' ;
10+ import { defineAllComponents } from 'igniteui-webcomponents' ;
11+ defineAllComponents ( ) ;
712
813import "./index.css" ;
914
1015export class Sample {
1116
1217 private grid : IgcGridComponent
18+ private column1 : IgcColumnComponent
1319 private _bind : ( ) => void ;
1420
1521 constructor ( ) {
1622 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 ;
1725
1826 this . _bind = ( ) => {
1927 grid . data = this . nwindData ;
28+ grid . addEventListener ( "cellEditEnter" , this . webGridOnEditEnter ) ;
29+ column1 . inlineEditorTemplate = this . webGridNumericColEditCellTemplate ;
2030 }
2131 this . _bind ( ) ;
2232
@@ -34,10 +44,45 @@ export class Sample {
3444 var context = this . _componentRenderer . context ;
3545 WebGridDescriptionModule . register ( context ) ;
3646 WebPaginatorDescriptionModule . register ( context ) ;
47+ WebInputDescriptionModule . register ( context ) ;
3748 }
3849 return this . _componentRenderer ;
3950 }
4051
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+
4186}
4287
4388new Sample ( ) ;
0 commit comments