Search code examples
databasegwtpaginationclient

Paging with a data set that can be changing?


I'm sure there is something out there about this topic but I just can't figure out how to word a search for it.

I have a table of records that gets loaded into a paging grid in the UI. The user has the ability to update/modify these records..also multiple users can use the system at once all hitting the same data. I have a filter on the paging grid allowing the user to see only X type of records.

When the user first enters with filter X selected they see items 1-25 on page 1 of 2. They page to the second page where the items should be 26-50..but before they paged lets say 25 records on the first page had their type changed by another user, now they don't appear when selecting that filter. So now we have 25 less items to page through which means items that were 26-50 before are now items 1-25 and what was page 2 is now page 1 and there is no page 2...

You can probably see the issue I'm getting into, I'm passing an offset to the query to get the next page of results..but now that offset is so high it returns a blank page of records confusing the user and our record processing.


Solution

  • There isn't really an easy solution to this problem. Even GMail/Google doesn't show the exact number of messages/pages found when searching something.

    The first thing you can do (if you use a DataGrid/CellTable) is set the boolean exact as false when you call updateRowCount, and give it your current number of records instead of your total number of records. This will make the pager display "1 - 25 of over 25" instead of "1 - 25 of 50".

    The next possibility is to update the row count regularly (using RPC polling to check for new/deleted records - or using server push techniques, see GWTEventService and ServerPushFAQ).

    You can also check if your request returns items or not, and cancel the call/update the row count if it doesn't.