I am using the ES5 DataGrid and my data source has over 2,000 items. I do not want to pass all 2,000 items to the client so I have enabled server-side paging to return an object that looks something like:
{
"count": 2643,
"items": [
--- 50 items returned, not all 2,643
]
}
As you can see, 50 items (paged on the server) are being sent to the client but there are 2,643 items remotely available.
I want to:
Hi Jordan Arron,
Thanks for contacting Syncfusion support.
In Our EJ2 DataManager, each adaptor expects the response from the server in a particular format to work properly. From your update, we suspect that you are using the “WebAPIAdaptor”. So, We suggest you sending the response starts with capital letters format like “Items” and “Count” to overcome the issue.
https://ej2.syncfusion.com/javascript/documentation/grid/data-binding/#web-api
If you still facing the issue, please share the below details that will be helpful for us to provide a better solution as early as possible.
Regards,
Pavithra S
Thanks for the reply. This is fantastic support :-)
The following is my code"
The api is returned the following:
{
Count: 8,
Items: [ {obj1}, {obj2} ]
}
The grid binds to the data correctly and is displaying 2 items.
I would expect the page to have 4 pages available and the text on the right to read "1 of 4 pages (8 items)" Instead, I am only seeing the following:
Hi Jordan Arron,
Thanks for sharing the details.
From your update, We understand that you are fetching only the one-page records and setting them as the Grid local dataSource and hardcode the “pageSettings” to have more “totalRecordsCount”. In Grid local data binding, the pager links will be rendered based on the dataSource length. This is the default behavior. Since you want to do the server-side paging, you can directly set the DataManager with WebAPIAdaptor to the Grid DataSource property. So, the pager links will be rendered based on the “Count” value, but the Grid will fetch and show only the current page records. Please refer to the below code example and documentation link for more information.
|
var url = 'https://my.api.endpoint';
grid = new ej.grids.Grid({ dataSource: new ej.data.DataManager({ url: url, adaptor: new ej.data.WebApiAdaptor(), }), allowPaging: true, pageSettings: { pageCount: 4 }, . . . });
|
Documentation : https://ej2.syncfusion.com/javascript/documentation/grid/data-binding/remote-data/#web-api-adaptor
demo : https://ej2.syncfusion.com/javascript/demos/#/material/grid/remote-data.html
If this still doesn’t meet your requirement, please share what are the issues you are facing with the above remote data bindings that will be helpful for us to provide a better solution as early as possible.
Regards,
Pavithra S
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.