How to select all rows in a paginated Grid with URLAdaptor

How can i select all Records in a paginated Grid with the URLAdaptor?

3 Replies

SE Sathyanarayanamoorthy Eswararao Syncfusion Team March 12, 2018 03:52 PM UTC

Hi Adrian, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and found that you need to select all the records in all the pages in grid. We have achieved your requirement in the following example using actionComplete avent and selectRows method of the grid. 


Refer the  below code example. 

 
<ej-grid id="Grid" allow-paging="true" is-responsive="true" min-width="500" enable-responsive-row="true" action-complete="complete" selectiontype="Multiple" > 
 
            …. 
 
                <e-datamanager url="/Home/DataSource" adaptor="UrlAdaptor" insert-url="/Home/Insert" update-url="/Home/Update" remove-url="/Home/Delete" ></e-datamanager> 
 
                …… 
 
            </ej-grid> 
 
<script> 
function complete(args) { 
       
        if (args.requestType == "paging") { 
            var length = this.model.currentViewData.length; 
            var lastindex = length - 1; 
            this.selectRows(0, lastindex); 
        } 
 
    } 
</script> 

Please refer the below documentation for details of actioComplete event and selectRows method of grid. 



If you need any  further assistance please get back to us. 

Regards, 
Sathyanarayanamoorthy 




AS Adrian Schafer March 12, 2018 08:16 PM UTC

Hi all

Thanks for the solution. But i want to send all the data from the filtered Grid to my Controller. I get only the Rows in the CurrentViewData. In my Case only 30 Rows. 

Regards,

Adrian



SE Sathyanarayanamoorthy Eswararao Syncfusion Team March 13, 2018 04:03 PM UTC

Hi Adrian, 

When Url Adaptor is used Filtered records cannot be accessed from the client side. When the records are filtered in grid dataSource method in server side triggered so we suggest you to use the data in the server side. 

Refer the below code example. 


 
public ActionResult DataSource([FromBody]DataManager dm) 
        { 
            IEnumerable data = _context.Orders.Take(100).ToList(); 
            DataOperations operation = new DataOperations(); 
            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting 
            { 
                data = operation.PerformSorting(data, dm.Sorted); 
            } 
            if (dm.Where != null && dm.Where.Count > 0) //Filtering 
            { 
                data = operation.PerformWhereFilter(data, dm.Where, dm.Where[0].Operator);   //here the filtered records are stored in data variable you can use this data when grid is filtered 
    
            } 
            int count = data.Cast<Orders>().Count(); 
            if (dm.Skip != 0) 
            { 
                data = operation.PerformSkip(data, dm.Skip); 
            } 
            if (dm.Take != 0) 
            { 
                data = operation.PerformTake(data, dm.Take); 
            } 
            return Json(new { result = data, count = count }); 
 
        } 
 
  
  
If you need any further assistance please get back to us. 

Regards, 
Sathyanarayanamoorthy 


Loader.
Up arrow icon