Hi support,
I am using an additional datastore to get my data from a restful service. I have a browse list of Item entities. The data is displaying the records from my restful service fine. The problem I am having is the pagination- it only shows all the records on one page. I cannot navigate from one page to another because only one page is accessible. However, the rows per page is working as expected to display the number of rows I want. See the image below:
When I compare using the project with main store (database), the pagination works fine.
Could it be that pagination does not work for additional datastore?
Hi,
You need to write paging implementation inside your custom datastore. The io.jmix.core.LoadContext.Query contains this information. After getting the firstResult and maxResults field values you’ll need to invoke your external service and get only required number of records from there.
Hi Maxim,
Thanks for your assistance as usual. I have tried what you suggested. Now the next, previous button of the pagination is clickable. However, it still does not move to the next page. The pagination does not navigate to the next list of records.
Hi,
Just adding more details to my question. I realize that the pagination is not numbered and the navigation is not triggering the loader. I am also having this error below
> Pagination component receives loader’s first result (0) that is out of last page range. Component may work incorrectly
Let me share the controller code behind if it will help:
There is no reason to have delegates in the screen controller. Try to remove them - in this case all requests should anyway come to the data store implementation.
Also, it seems that the long getCount() method in the data store should return the total count of all records.
Hi Maxim,
Thanks for your response. I have removed all the screen controller. All requests are going to the data store implementation which in turn calls my REST services calls. The getCount() is returning the size().
However, the pagination is not splitting into pages yet. The next and previous buttons are all grayed out. They are not clickable. All the records are pulling in one page no matter Rows per page number I choose. What could be wrong with my implementation?
If all records are displayed then it probably means that your businessPartnerService.loadCustomers(context) doesn’t take the paging information into account and always returns all records received from the REST service.
Hi Le Duy,
I think the problem with your code is that you are putting the pagination in the wrong place.
Your pagination should be within the layout, not within the data.
See example below:
Also, check the documentation about pagination
Hi,
I have had this same issue before while I was starting to learn how pagination works. The reason you are having the pagination on one page is because you are not setting the total count.
For example, let say your rest api service is returning scorecard of 100 records but you want to page 20 records per page. You need to return the total count of records in this case 100 along side the result you are getting from your service.
Check all Maxim’s answers above. It should guide you.