When I am triyng to assign new data to the data source, on beforeDataBound() method, the pagination is not working properly.

When I am triing to assign new data to the data source, on beforeDataBound() method, the pagination is not working properly, when I click on 3rd page, it is moving to 1st page. I am trying to send page no. to backend to achieve dynamic paging. PLease help me out on this as this is on critical stage.








 


When I click 2, it is going to 1


1 Reply

PS Pavithra Subramaniyam Syncfusion Team August 24, 2022 07:11 AM UTC

Hi Yashwanth,


Thanks for contacting Syncfusion support.


From your update, it seems that you are trying to set the totalRecordsCount more than the actual records, fetch the current page data from a service, and set that data to the Grid dataSource property. To work the Grid paging properly, we need to bind the Grid dataSource which should be matched with the total records count. In your sample, we suspect that, while clicking the 2nd page, only the 2nd page records are set as the entire Grid dataSource. So, the Grid will have only one page records. For example, if the page Size is 12 then the grid will have only 12 records which will be considered the first page records. Due to this the Grid will navigate to the first page which is the default behavior.


We understand that you want to load only the current page data from the server, not the entire data. To achieve your requirement, we have options like Load on demand using our Adaptors or Custom Data binding. Using these we could send a request to the server to fetch the required page data and the total count. So, the page links will be rendered based on the count and while clicking the link, the next set of data will be fetched from the server and displayed in the Grid. Please refer to the below documentation link for more information.


Documentation:  https://ej2.syncfusion.com/angular/documentation/grid/data-binding/remote-data/

                               https://ej2.syncfusion.com/angular/documentation/grid/observables/#observables


                              https://ej2.syncfusion.com/angular/documentation/grid/observables/#handling-grid-actions


demo                  : https://ej2.syncfusion.com/angular/demos/#/material/grid/remote-data

                               https://ej2.syncfusion.com/angular/demos/#/material/grid/async-pipe


If this still doesn’t meet your requirement, please share the below details that will be helpful for us to provide a better solution as early as possible.


  1. Why do you want to change the Grid dataSource inside the beforeDataBound event?
  2. What are the issues you are facing with the above remote/custom data bindings?
  3. Share the initial Grid dataSource value


Regards,

Pavithra S


Loader.
Up arrow icon