How to get grid selected records index from all pages in multi checkbox feature when using remote data

Hi,
I am trying to get selected records from grid (multi checkbox) but, grid datasource is not local so, grid instance object model datasource only have current page records.
I have been looking in forums but only get solution for local datasource.
I will appreciate your help,
Kind regards,
Juan J. Uribe

3 Replies

VN Vignesh Natarajan Syncfusion Team January 11, 2018 12:32 PM UTC

Hi Juan, 

Thanks for using Syncfusion products. 

Query: “How to get grid selected records index from all pages in multi checkbox feature when using remote data” 

We have analyzed your query and we have achieved your requirement using checkSelectedRowIndexes property of the Grid. Already we have discussed your requirement in knowledge base document which can be referred from below link 


KB explains how to get selected records for local data. For remote data, we have sent the ajax post to the server with the selected indexes array and filter the records from the Database.   

Refer the below code snippet 

           console.log(rec); 
              $.ajax({ 
                  url: '@Url.Action("GetDocs")', 
                  type: "POST", 
                  contentType: 'application/json; charset=utf-8', 
                  data: JSON.stringify ({ value: rec }), 
                  success: function (data) { 
                      console.log(data)                      
                  } 
              }) 

C# 

public ActionResult GetDocs(int[] value) 
        { 
            List<Order> Rec = new List<Order>(); 
            NorthwindDataContext db = new NorthwindDataContext(); 
            var DataSource = db.Orders.ToList(); 
            for (int i = 0; i< value.Length; i++) 
            { 
                Rec.Add(DataSource.ElementAt(value[i]));    
                             
            } 
            return Json(Rec, JsonRequestBehavior.AllowGet); 
        } 

In above code rec value is calculated using procedure given in KB. 

Refer the below screenshot for the output 

 

For your convenience we have prepared a sample which can be viewed from below link 

Regards, 
Vignesh Natarajan 



JJ Juan Jose Uribe January 11, 2018 09:26 PM UTC

I haven't understood the code first time I saw the solution in KB, was not very clear to me but, now I've got the idea.
Thanks so much, I could get what i wanted.

Kind regards,
Juan J. Uribe


VN Vignesh Natarajan Syncfusion Team January 12, 2018 12:24 PM UTC

Hi Juan, 
  
Thanks for the update. 
  
We are happy to hear that your query has been resolved.  
  
please get back to us if you need further assistance. 
  
Regards, 
Vignesh Natarajan. 


Loader.
Up arrow icon