0
votes

I am using a DataGrid together with a ListDataProvider to display various row data in my application. For most cases, it was fine to fetch everything from the server at once. Now, it appears to be necessary to fetch data on pagination steps. This means, my RPC call returns 10 items each time and the total count of possible results.

The total count is used to setup the attached SimplePager by manually calling datagrid.setRowCount(totalCount, true) after having set the row data. After is important here, because setRowData also triggers a setRowCount call with the concrete number of items (always 10 in my case).

The problem is that after having set the row count manually, another participant, a ScheduledCommand triggers a flushCommand which in turn triggers a setRowCount call which sets the count back to 10. The consequence: the pager shows 1-10 of 10 and the pager controls are disabled.

How can I enforce a certain rowCount even if the ListDataProvider only has 10 items each time?

You might suggest to use an AsyncDataProvider. However, there already is a quite complex generic design (AbstractTablePresenter<DTO, ...> implementing all the logic to fetch data and push it to a generic display) which is backed by ListDataProviders. Hard to explain, but actually, I would prefer keep using the ListDataProvider.

1
How you handle the next page request?Fedy2
My presenter is registered as handler for rangeChangeEvents and triggers RPC calls which load the data of the current page.rainer198

1 Answers

0
votes

For my usecase, the easiest fix was to subclass my AbstractTablePresenter for the on-demand case and use an AsyncDataProvider which brings all the features I need. The hurts concerning my design was less heavy than expected (knocking on my shoulders ;-) ).

Tried to subclass ListDataProvider first but the relationship of data, rowCount, rowCountEvents and the attached pager objects is so manifold that you would end up overriding most of the methods of ListDataProvider and your pager implementation.