Because our RESTful API doesn't use the result/count response style but a flat array and `X-Total-Count` header, I figured I had to write a custom data adapter.
class ApiAdaptor extends UrlAdaptor {
processQuery(dm: DataManager, query: Query, hierarchyFilters?: Object[]) {
let original = super.processQuery.apply(this, arguments);
let data = JSON.parse(original.data);
return {
data: JSON.stringify({ value: data }),
url: `${original.url}?offset=${data.skip}&limit=${data.take}`,
pvtData: original.pvtData,
type: 'GET',
contentType: 'application/json; charset=utf-8'
};
}
processResponse(data, ds, query, xhr, request, changes) {
return {
result: super.processResponse.apply(this, arguments),
count: xhr.getResponseHeader('X-Total-Count')
};
};
}
The grid component has [enableVirtualization]=true and I've loaded VirtualScrollService as a provider.
It does seem to work fine but virtual scrolling doesn't work properly with this adapter. If I scroll down, right before the point where subsequent data will be loaded and then scroll down a row further, the new data is loaded and rendered on the grid from the top down. Of course, the new data should only be rendered in the open space at the bottom. In other words: when the new data is loaded, the grid is effectively scrolled all the way to the point where the new data was loaded.
This results in a jumping grid experience.
Is there something I'm doing wrong?