BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hi Roman,
Thanks for using Syncfusion products.
Query 1: I need to select multiple items from a grid, but when i change the page of the grid, the selection from the previous page disappears. How can I prevent it?
Based on your requirement we have created the sample and the same can be downloaded from the following link.
Sample Link: MVC_Sample_-_12.3.0.36.zip
In the above sample we have used “_selectedRowsIndexes” for getting selected rows of the current page in ActionBegin clientside event of the grid.
Please refer the below code snippet.
@(Html.EJ().Grid<object>("Grid") . . . . }).ClientSideEvents(eve => { eve.ActionBegin("begin").ActionComplete("complete"); }) )
<script type="text/javascript">
function begin(args) { if (args.requestType == "paging")
{ var gridobj = $("#Grid").data("ejGrid"); for (var i = 0; i < gridobj._selectedRowsIndexes.length; i++) {
selectedRecords.push({ rowIndex: args.previousPage, selectedRecordsIndex: gridobj._selectedRowsIndexes[i] }); } } } </script> |
And
also in the ActionComplete event of
the grid we have selected the rows by passing the selected indices in to the selectRows method of the grid.
<script type="text/javascript"> function complete(args) { for (var i = 0; i < records.length; i++) { gridobj.multiSelectCtrlRequest = true; gridobj.selectRows(records[i]); } } } </script> |
For your kind information, In our current implementation we don’t have public property for “_selectedRowIndexes” private variable and also we have confirmed that an issue with “Need public property for _selectedRowIndexes private variable” is a defect and also please create a new incident for better follow up.
Query 2: One more question: how can I get all records from the grid?
We can get all the records from the grid using “dataSource” property as follows.
<script type="text/javascript"> function begin(args) { var data = args.model.dataSource; } |
Please try the sample and let us know if you have any queries.
Regards,
Gowthami V.
Hi Roman,
Thanks for your update.
Please get back to us if you have any queries. We will happy to assist you.
Regards,
Gowthami V.