1- import { type Column , type GridOption , SlickEventHandler } from '@slickgrid-universal/common' ;
1+ import { type Column , type GridOption , SlickEventHandler , Editors } from '@slickgrid-universal/common' ;
22import { Slicker , SlickVanillaGridBundle } from '@slickgrid-universal/vanilla-bundle' ;
33import { ExampleGridOptions } from './example-grid-options' ;
44import './example19.scss' ;
55
66const NB_ITEMS = 100 ;
7+
78export default class Example19 {
89 protected _eventHandler : SlickEventHandler ;
910
@@ -13,6 +14,7 @@ export default class Example19 {
1314 gridContainerElm : HTMLDivElement ;
1415 isWithPagination = true ;
1516 sgb : SlickVanillaGridBundle ;
17+ isGridEditable = true ;
1618
1719 attached ( ) {
1820 this . _eventHandler = new SlickEventHandler ( ) ;
@@ -52,7 +54,7 @@ export default class Example19 {
5254 id : 'selector' ,
5355 name : '' ,
5456 field : 'num' ,
55- width : 30
57+ width : 30 ,
5658 }
5759 ] ;
5860
@@ -62,9 +64,10 @@ export default class Example19 {
6264 name : i < 26
6365 ? String . fromCharCode ( 'A' . charCodeAt ( 0 ) + ( i % 26 ) )
6466 : String . fromCharCode ( 'A' . charCodeAt ( 0 ) + ( Math . floor ( i / 26 ) ) - 1 ) + String . fromCharCode ( 'A' . charCodeAt ( 0 ) + ( i % 26 ) ) ,
65- field : i as any ,
67+ field : String ( i ) ,
6668 minWidth : 60 ,
6769 width : 60 ,
70+ editor : { model : Editors . text }
6871 } ) ;
6972 }
7073
@@ -74,6 +77,8 @@ export default class Example19 {
7477 } ,
7578 enableCellNavigation : true ,
7679 enablePagination : true ,
80+ autoEdit : true ,
81+ editable : this . isGridEditable ,
7782 pagination : {
7883 pageSizes : [ 5 , 10 , 15 , 20 , 25 , 50 , 75 , 100 ] ,
7984 pageSize : 20
@@ -119,4 +124,11 @@ export default class Example19 {
119124 this . sgb . paginationService ! . togglePaginationVisibility ( this . isWithPagination ) ;
120125 this . sgb . slickGrid ! . setSelectedRows ( [ ] ) ;
121126 }
127+
128+ toggleGridEditReadonly ( ) {
129+ // then change a single grid options to make the grid non-editable (readonly)
130+ this . isGridEditable = ! this . isGridEditable ;
131+ this . sgb . gridOptions = { editable : this . isGridEditable } ;
132+ this . gridOptions = this . sgb . gridOptions ;
133+ }
122134}
0 commit comments