@@ -8,6 +8,11 @@ export class GridEditorComponent implements OnInit {
88 title = 'Example 3: Editors' ;
99 subTitle = `
1010 Grid with Inline Editors and onCellClick actions (<a href="https://github.com/ghiscoding/Angular-Slickgrid/wiki/Editors">Wiki link</a>).
11+ <ul>
12+ <li>When using "enableCellNavigation: true", clicking on a cell will automatically make it active & selected.
13+ <ul><li>If you don't want this behavior, then you should disable "enableCellNavigation"</li></ul>
14+ <li>Inline Editors requires "enableCellNavigation: true" (not sure why though)</li>
15+ </ul>
1116 ` ;
1217
1318 columnDefinitions : Column [ ] ;
@@ -27,25 +32,24 @@ export class GridEditorComponent implements OnInit {
2732 formatter : Formatters . editIcon ,
2833 minWidth : 30 ,
2934 maxWidth : 30 ,
30- /*
3135 // use onCellClick OR grid.onClick.subscribe which you can see down below
3236 onCellClick : ( args : OnEventArgs ) => {
3337 console . log ( args ) ;
3438 alert ( `Editing: ${ args . dataContext . title } ` ) ;
35- }*/
39+ this . gridExtraService . highlightRow ( args . row , 1500 ) ;
40+ this . gridExtraService . setSelectedRow ( args . row ) ;
41+ }
3642 } ,
3743 {
3844 id : 'delete' , field : 'id' ,
3945 formatter : Formatters . deleteIcon ,
4046 minWidth : 30 ,
4147 maxWidth : 30 ,
42- /*
4348 // use onCellClick OR grid.onClick.subscribe which you can see down below
4449 onCellClick : ( args : OnEventArgs ) => {
4550 console . log ( args ) ;
4651 alert ( `Deleting: ${ args . dataContext . title } ` ) ;
4752 }
48- */
4953 } ,
5054 { id : 'title' , name : 'Title' , field : 'title' , sortable : true , type : FieldType . string , editor : Editors . longText } ,
5155 { id : 'duration' , name : 'Duration (days)' , field : 'duration' , sortable : true , type : FieldType . number , editor : Editors . text ,
@@ -102,6 +106,9 @@ export class GridEditorComponent implements OnInit {
102106 this . updatedObject = args . item ;
103107 this . resizer . resizeGrid ( this . gridObj , this . gridOptions , 10 ) ;
104108 } ) ;
109+
110+ // You could also subscribe to grid.onClick
111+ // Note that if you had already setup "onCellClick" in the column definition, you cannot use grid.onClick
105112 grid . onClick . subscribe ( ( e , args ) => {
106113 const column = GridExtraUtils . getColumnDefinitionAndData ( args ) ;
107114 console . log ( 'onClick' , args , column ) ;
0 commit comments