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

Server Side pagination with custom filter

I have a table with 5 fields. It is formed from a filter in which there are dozens of parameters. How to organize server pagination?

13 Replies

MA Mohanram Anbukkarasu Syncfusion Team December 9, 2019 12:34 PM UTC

Hi Dima,   
  
Thanks for contacting Syncfusion support.   
  
We are not clear about query SfDataPager and the term “organize server pagination”. Can you please provide us more details about your requirement and the need for the SfDataPager in your application? So that we could analyze and provide you solution at the earliest.    
  
Regards,   
Mohanram A  



DI Dima December 10, 2019 12:38 PM UTC

I have a form with filters. The filter is sent to the server and receives a table in response. There can be a lot of data in the table, and for this reason paging is needed. Your 2 controls SfDataPager and SfDataGrid already work for me. How can I change the non-server version, under the server


MA Mohanram Anbukkarasu Syncfusion Team December 11, 2019 01:05 PM UTC

Hi Dima,   
  
Thanks for the update.    
  
You are using SfDataPager and SfDataGrid for handling the large data received from the server. But we are unclear about your requirement in the server. Please elaborate your requirement for SfDataPager and SfDataGrid in server. The provided details are insufficient to understand your requirement and to replicate your scenario. Please provide more information about your requirement in detail like what you have already done and what you are trying to do with some illustrations if possible. This will help us to understand your scenario and to provide you a solution.   
  
Regards,   
Mohanram A  



DI Dima December 12, 2019 12:01 PM UTC

I attached the code - this is part of the whole project, cut out everything that is not related to this issue. There is a method that receives a list of objects by the filter and places them in SfDataPager, and SfDataGrid ItemsSource = "{Binding ElementName = sfDataPagerSbobet, Path = PagedSource}". I need an option when in the calculation I get the 1st page and the total number of lines. Based on this control, it builds line numbering, and when the buttons are switched, another request to the server is made, in order to obtain the necessary data, the corresponding page is pressed and displayed in SfDataGrid.

Attachment: ServerSideGrid_51428d72.zip


MA Mohanram Anbukkarasu Syncfusion Team December 13, 2019 11:32 AM UTC

Hi Dima,   
  
Thanks for the update.    
  
We suspect that your requirement is to remain on the current page when new pages are added due to addition of data from the server. It can be achieved by using setting the same page index to the SfDataPager after the list of objects are received from the server as shown in the below code example.    
  
Code example:    
  
<Button Content="Рассчитать" VerticalAlignment="Bottom" Margin="15,15,20,50" HorizontalAlignment="Right" Height="50" Width="{Binding ElementName=xgtoggleBtn, Path=ActualWidth,UpdateSourceTrigger=PropertyChanged}"  Panel.ZIndex="100" CommandParameter="{Binding ElementName=sfDataPagerSbobet}" Command="{Binding Path=SaveCommand}"></Button> 
 
 
public void Execute(object parameter) 
{ 
     var dataPager = (parameter as SfDataPager); 
     var currentPageIndex = dataPager.PageIndex; 
     this.execute(parameter); 
     if (currentPageIndex < dataPager.PageCount) 
         (parameter as SfDataPager).PageIndex = currentPageIndex; 
} 
  
   
We have modified the provided sample to generate random data and this requirement and it is available in the below link for your reference.    
  
  
Please refer the above sample and let us know if we have misunderstood your requirement.   
  
Regards,   
Mohanram A  




DI Dima December 13, 2019 03:45 PM UTC

This is not what I asked for. I need to get only the 1st page out of 100 from the server at the click of a button. In order for the SfDataPager control to display 100 pages, it needs to put a list of 100 * PageSize in Source. Then he will draw these 100 pages at his place. And there will be an opportunity to pass to other pages.

How can I show 100 pages in SfDataPager without putting 100 * PageSize elements in its source? I would update the data in the table by the SfDataPager.PageIndexChanging event - I would get a new SfDataPager index, make a request with this index to the server and display this list of data in the table.


MA Mohanram Anbukkarasu Syncfusion Team December 16, 2019 01:27 PM UTC

Hi Dima, 

Thanks for the update.  

We are still unclear with your requirement “How can I show 100 pages in SfDataPager without putting 100 * PageSize elements in its source? “. Let us consider the PageSize of SfDataPager is 15 and on a button click you are receiving 45 records from the server. We suspect that your requirement is to get only first 15 records from the server on the button click and to get next 15 records when the button is clicked again and so on.  
Kindly provide details about your requirement with some illustrations as specified above. It will be helpful for us to understand your exact requirement and to provide the possibilities to achieve the same without any further delay. 

We regret for the inconvenience. 

Regards, 
Mohanram A. 



DI Dima December 17, 2019 11:54 AM UTC

You got it right. I have a method that returns an object of type: 
{objs: [{...}, .., {..}], countAll: 45, page: 1, countOnPage: 15}. 
objs has 15 elements. I need to show 3 pages in the SfDataPager control, select the first page and show in SfDataGrid those 15 elements that came. But at the page change event in SfDataPager, you need to make an additional request to the north to receive the 2nd page with the following 15 elements 
{objs: [{...}, .., {..}], countAll: 45, page: 2, countOnPage: 15}.


SS Susmitha Sundar Syncfusion Team December 18, 2019 12:10 PM UTC

  
Hi Dima,  
  
  
Thank you for your update.  
  
Based on your provided details, we suspect that you need to load the data while clicking on the pager buttons. If so, you can use the OnDemandPaging for SfDataPager. Please find more details from below UG documentation,  
  
  
  
Please revert us, if you need further assistance.  
  
Regards,  
Susmitha S  



DI Dima January 28, 2020 03:04 PM UTC

Yes, that was what I needed. But there is a problem with data model binding. I attach pieces of code - I can not send all the code.

When switching to the next page, OnDemandLoading is triggered - I get a new portion from the server in it and execute sfDataPager.LoadDynamicItems (args.StartIndex, items); The index in sfDataPager switches to the next, but the data page is not displayed. you must manually click on the page number itself in sfDataPager to update the data - the same behavior if you click on the page numbers themselves in sfDataPager. I will attach the video and code

In the video archive, the control with SfDataGrid and sfDataPager and the data model for this control.

Attachment: Views_6526356b.zip


SS Susmitha Sundar Syncfusion Team January 29, 2020 11:28 AM UTC

Hi Dima,   
   
Thank you for using Syncfusion controls.   
   
We have checked the reported issue and we are unable to replicate the issue from our end. OnDemandLoading works fine when click the both navigation button and page number button. We have prepared a sample for your reference.   
   
  
We have tested with Syncfusion version 17.4.0.39.   
   
Please check the above sample and revert us if you still facing the same issue? If yes, please modify the sample based on your scenario. It will be helpful for us to check on it and provide you the solution at the earliest.     
   
Regards,   
Susmitha S   



UK Ulfried Koch replied to Susmitha Sundar June 17, 2020 01:22 PM UTC

Dima Replied On January 28, 2020

" I get a new portion from the server in it and execute sfDataPager.LoadDynamicItems (args.StartIndex, items); The index in sfDataPager switches to the next, but the data page is not displayed. you must manually click on the page number itself in sfDataPager to update the data "


I can confirm that this happens with our on-demand paging too. Grid shows an empty page - only after manually clickickig on the Page-Button, the data comes in.
We are using still 15.4.20 I wrote an workaround like this:

  public async static void DataPagerMoveToPage(int page)
        {

            resultDocumentsDataPager.PagedSource.ResetCacheForPage(page);
            resultDocumentsDataPager.MoveToPage(page);

            // check if MoveToPage was sucessfull (we have some data)
            if (resultDocumentsDataPager.PagedSource.Count > 0)
            {
                return;
            }

            // Workaround: Syncfusion shows sometimes only an empty page.
            // In this case we repeat until we have some data. Usully data are
            // coming in after 2-5 repeats.
            // In any case, we do not wait longer than 1000 ms.
            for (int i = 0; i < 50; i++)
            {
                if (resultDocumentsDataPager.PagedSource.Count == 0)
                {
                    await Task.Delay(20);
                    resultDocumentsDataPager.MoveToPage(page);
                }
                else
                {
                    break;
                }
            }
        }

would be great to have better solution..



VS Vijayarasan Sivanandham Syncfusion Team June 18, 2020 04:57 PM UTC

Hi Ulfried Koch,

Thank you for contacting Syncfusion support.

We have checked the reported issue “The index in sfDataPager switches to the next, but the data page is not displayed” and unable to replicate the issue from our end. We have tested with Syncfusion version 15.4.0.20. it is working fine as expected. Please find the tested sample and video demo from our end in the below link,
 
   
if you still facing the same issue? If yes, please modify the sample based on your scenario.  
   
It will be helpful for us to check on it and provide you the solution at the earliest.     
   
Regards,   
Vijayarasan S

 


Loader.
Live Chat Icon For mobile
Up arrow icon