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. Image for the cookie policy date

(Paging question) Is it possible to set PageCount while using OnDemandLoading depending on elements count?


I use your SfDataGrid in my project in Xamarin.Forms. But I have a problem. I should use paging in my case, but I can't use normal paging because I have much data to load. So I use OnDemandLoading, but I can't understand how to bind PageCount (which must be setted) with number of my data. As example: I have 5000 rows and 20 rows per page, so PageCount should be equals 5000/20 = 250. I can never use PageCount = 250 because I always have different number of rows.

Could you tell me please what I can do in this case?

Best regards,

1 Reply

SP Subburaj Pandian Veluchamy Syncfusion Team April 19, 2019 09:03 AM UTC

Hi Alexandr 
Thank you contacting Syncfusion support. 
How to define page count for OnDemandPaging 
We have checked your requirement of “Changing the page count for DataPager and it will change based on the records count”, refer the following code snippet to change the page count in OnDemandLoading. 
private void DataPager_OnDemandLoading(object sender, Syncfusion.SfDataGrid.XForms.DataPager.OnDemandLoadingEventArgs args) 
    dataPager.LoadDynamicItems(args.StartIndex, viewModel.OrdersInfo.Skip(args.StartIndex).Take(args.PageSize)); 
    //Here we have modified the page count when we generate items for third page. Modify the pagecount based on your requirement. 
    if (args.StartIndex == 30) 
        //Initially 10 buttons are generated now changed to 5. 
        dataPager.PageCount = 5; 
We also attached the sample (SfDatGrid version for your reference, 
Please get in touch with us if you would require any further assistance. 
Subburaj Pandian V 

Live Chat Icon For mobile
Up arrow icon