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.
Unfortunately, activation email could not send to your email. Please try again.

Problem with multiple selection

Thread ID:

Created:

Updated:

Platform:

Replies:

117686 Nov 27,2014 08:24 AM Dec 3,2014 11:38 PM ASP.NET MVC 4
loading
Tags: Grid
Roman Suska
Asked On November 27, 2014 08:24 AM

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

Roman Suska
Replied On November 28, 2014 08:35 AM

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

Gowthami V [Syncfusion]
Replied On November 28, 2014 12:04 PM

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.


Roman Suska
Replied On December 3, 2014 03:46 AM

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

Gowthami V [Syncfusion]
Replied On December 3, 2014 11:38 PM

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.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;