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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Rows Selection & Pagination

Thread ID:

Created:

Updated:

Platform:

Replies:

127728 Dec 5,2016 04:13 PM UTC Dec 9,2016 04:26 AM UTC ASP.NET MVC 3
loading
Tags: Grid
indrani Gajjarapu
Asked On December 5, 2016 04:13 PM UTC

Hi,

I have a grid with a checkbox column to select the rows.

However, if i select few records in Page 1 and few in Page 2, getSelectedRows method gives the rows selected in Page 2 only.

Previous page selected rows are automatically unchecked when i move to different page.

How can i overcome this issue??!!.

Venkatesh Ayothi Raman [Syncfusion]
Replied On December 6, 2016 07:13 AM UTC

Hi Indrani, 
Thanks for contacting Syncfusion support. 

The getSelectedRecords method will return only the current page selected records.  
In this, we can get the stored selected records and current page selected records and merge the both array’s using ej.merge function. We have achieved your requirement using additional property for storing the selected records in the grid, 
Code example
@Button 
<input type="button" value="GetSelectedRecords" id="SelectedRecords" /> 
@Grid 
@(Html.EJ().Grid<OrdersView>("FlatGrid") 
        .Datasource((IEnumerable<object>)ViewBag.datasource) 
        .AllowPaging()         
         
                                    .ClientSideEvents(eve => 
                                    { 
                                 
                                    eve.ActionBegin("actionBegin"); 
                                    eve.DataBound("dataBound");}) 
 
        .Columns(col => 
        { 
            col.Type("checkbox").Width(50).Add(); 
              . . . 
 
        })) 
 
@dataBound 
 
    function dataBound(args) { 
        this.model.records = {}; /* Additional property*/ 
    } 
@actionBegin 
function actionBegin(args) { 
        if (args.requestType == "paging") { 
            if (this.selectedRowsIndexes.length > 0) 
                this.model.records[args.previousPage] = this.getSelectedRecords(); //Store the selected records  
        } 
    } 
@Button function 
$("#SelectedRecords").ejButton({ click: "getMergedSelected" }); 
 
    function getMergedSelected() { 
 
        var obj = $("#FlatGrid").ejGrid("instance"); 
 
        var r = obj.model.records, selected = []; 
 
        for (var p in r) { 
            ej.merge(selected, r[p]); 
        } 
 
        ej.merge(selected, obj.getSelectedRecords()); 
 
        return selected;// All selected records 
    } 
 

Help document


Regards, 
Venkatesh Ayothiraman. 


indrani Gajjarapu
Replied On December 8, 2016 10:15 AM UTC

Hi Venkatesh,

Thank for the reply..It worked..

Mohammed Farook J [Syncfusion]
Replied On December 9, 2016 04:26 AM UTC

Hi Indrani
  
Thanks for updated.  
  
Regards, 
J.Mohammed Farook 


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.

Warning Icon 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.Close Icon

;