DataBind to paging REST API

Hi - I have a very slow SfGrid, and this could be because of the amound of data when OnInitializedAsync. The load is 3,5-4 mb of Json, 3000-4000 rows. 

Therefore I have extented the REST.API to be able to return pages, but how is the smartest way to bind to a paging API?
  
I looked at:
  <SfGrid TValue="Order" AllowPaging="true">
                                    <SfDataManager Url="https://secretURL.net/api/GetOrders?CustomerId=1&PageOffset=0&PageSize=30"
                                                Adaptor="Adaptors.WebApiAdaptor" Offline="true"></SfDataManager>

but can I bind directly to grid paging with SfDataManager or do I have to write my own controller, with API calls from pagenumbers in the datagrid?


1 Reply

RS Renjith Singh Rajendran Syncfusion Team May 13, 2020 10:26 AM UTC

Hi Soren, 

Greetings from Syncfusion support. 

We suggest you to remove the Offline property from SfDataManager and handle the paging action server side by using the below codes. In the Request.Query we will get the paging request query string, you can use it to handle the paging at server side as like the below codes. We have also prepared a sample to handle paging at server side in WebApi service. Please download the sample from the link below, 
 
 
    <SfGrid TValue="Orders" AllowPaging="true">  
        <SfDataManager Url="api/Default" Adaptor="Adaptors.WebApiAdaptor" Offline="true"></SfDataManager> 
        ... 
    </SfGrid> 
 
        [HttpGet] 
        public async Task<object> Get() 
        { 
            ... 
           var data = order.AsQueryable();             
            var queryString = Request.Query; 
            string auto = queryString["$inlineCount"]; 
            if (queryString.Keys.Contains("$inlinecount")) 
            { 
                StringValues Skip; 
                StringValues Take; 
                int skip = (queryString.TryGetValue("$skip", out Skip)) ? Convert.ToInt32(Skip[0]) : 0; 
                int top = (queryString.TryGetValue("$top", out Take)) ? Convert.ToInt32(Take[0]) : data.Count(); 
                var count = data.Count(); 
                return new { Items = data.Skip(skip).Take(top), Count = count }; 
            } 
            ... 
       } 
 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 


Loader.
Up arrow icon