- Home
- Forum
- JavaScript - EJ 2
- Setting the page index and query prior to calling backend v29
Setting the page index and query prior to calling backend v29
Hi,
I have a setup where I use a DataManager and custom adapter with a Grid component. I've implemented an external <form> from which I generate a Query object and then assign it to the grid (I set the pageIndex to 1 with qury.page(1,10). this automatically triggers a request to the backend to fetch the data. The data is fetched, the page number is set to 1. (this worked correctly with EJ2 version 23)
After updating to version 29, this doesn't work anymore, and the pageIndex is left unchanged for the request. This is a problem, as the user will expect to start from page 1, when he uses the search form.
I can change the page index afterwards, but this results in a new call to the backend (this is not desirable, as it is slow and unnecessary).
I've tried changing the pageIndex prior of assigning the query, still there is an extra request.
I've tried controlling the pageIndex in the adapter, but the grid, doesn't take the returned pageIndex from the response, and it continues to show the old page index.
I prepared extremely stripped down example of what i'm trying to achieve here https://stackblitz.com/edit/stackblitz-starters-omzecq4y
In the example, There is a grid with DataManager and simple form and button. Pressing the button, activates the function searchGrid(). It prepares the query and assign it. The getRequestQuery() in CustomDataAdaptor console.logs the pageIndex it receives.
I expect if the user goes to page 2 of the grid and then presses the search button, to receive pageIndex 1, as it is specified in the query.
Please ignore the fact that the data is not changing, as I used demo data from syncfusion's demo pages.
Thanks
Hi Julian Calderon,
Greetings from Syncfusion support!
As per our understanding, you mentioned that in version 23 the pageIndex was automatically reset to 1 when applying a new query, but after upgrading to version 29, the pageIndex retains the current value (for example, stays on page 2) — even after performing a search.
Please note that this is the default behavior of the Grid component — when applying a new query, the page index will not automatically reset to the first page. If the query result contains more records exceeding the page size, the Grid will remain on the current page (e.g., page 2)
We have tested this scenario on our end in both versions (23 and 29) and observed that the Grid returns the current pageIndex in both cases.
Sample Link in 23 version : https://stackblitz.com/edit/stackblitz-starters-bfdnqn86?file=index.html,script.js
Video Demo (23.):
Sample Link in Latest version(29.1.37): https://stackblitz.com/edit/stackblitz-starters-lbs1fsv3?file=CustomDataAdaptor.js
Video Demo(29.) :
To assist you better, we kindly request you to provide more details about your exact requirement.
- What is your exact requirement in this scenario?
- Kindly share a runnable which will return to the first page using version 23, so that we can compare the behavior and identify any differences or issues.
Once we have these details, we will be able to assist you more effectively.
- 1 Reply
- 2 Participants
-
JC Julian Calderon
- Apr 2, 2025 10:06 AM UTC
- Apr 8, 2025 11:02 AM UTC