We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Problem with multiple selection

Hello,
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?
Greetings
Roman Suska

4 Replies

UN Unknown Syncfusion Team November 28, 2014 01:35 PM UTC

One more question: how can I get all records from the grid?


GV Gowthami V Syncfusion Team November 28, 2014 05:04 PM UTC

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.



UN Unknown Syncfusion Team December 3, 2014 08:46 AM UTC

Hello,
everything works now, thank you for help.
Greetings
Roman Suska


GV Gowthami V Syncfusion Team December 4, 2014 04:38 AM UTC

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.


Loader.
Live Chat Icon For mobile
Up arrow icon