HI
we have implemented the tree grid with pagination and also it contains the checkbox ,
to get the selected checkbox we using the rowselected() method .
The problem is when we move to next page the selected checkbox is not retained , the variable is getting reset everytime when we move to next pages .
how to select the checkbox values when I move to any page in angular 12 tree grid using syncfusion .
Hi Dileep,
By default Selection won’t persist on performing TreeGrid actions as well as on TreeGrid refresh. In order to persist the selection on performing operations such as paging we need to set persistSelection of selectionSettings property as true. Based on this getSelectedRecords method gets maintained with selected records upon Paging.
Refer to the code example:-
|
App.Component.html <ejs-treegrid #treegrid [dataSource] = 'data' allowPaging = 'true' childMapping = 'subtasks'[treeColumnIndex] = '1'[selectionSettings] = 'selectionsettings' > <e-columns> <e-column type='checkbox' width='50'></e-column> <e-column field='taskID' headerText='Task ID' isPrimaryKey='true' width='70' textAlign='Right'></e-column> . . . </e-columns> </ejs-treegrid>
App.component.ts ngOnInit(): void { this.data = sampleData; this.selectionsettings = { persistSelection: true }; } |
Refer to the API and Documentation Link:-
https://ej2.syncfusion.com/angular/documentation/api/treegrid/selectionSettings/#persistselection
Sample link:- https://stackblitz.com/edit/angular-jwyrt8?file=app.component.html
https://ej2.syncfusion.com/angular/documentation/treegrid/selection/#checkbox-selection
Please get back to us if you need any further assistance.
Regards,
Farveen sulthana T
Hi
can you please provide the solution for a ejs-grid ?
can we apply the persistent selection for the ejs-grid as well ?
Hi Dileep,
Thanks for the update
To persist the selection while performing paging, we need to set persistSelection of selectionSettings property as true. We have already discussed your requirement in our sample demos which can be accessed from the below link,
Sample Demos: https://ej2.syncfusion.com/angular/demos/#/material/grid/checkbox-selection
API: https://ej2.syncfusion.com/angular/documentation/api/grid/selectionSettings/#persistselection
Regards,
Rajapandi R