Changes in Grid filter is not redirecting to first page.
How do you automatically force/refresh the grid paging results to go to the first page (ie page 1 of x) upon loading?
I have a filter control which, if activated when a user is on (for example) page 3 of 5, refreshes the results to a subset which doesn't even go past 1 page, the user is presented with a blank grid and a paging toolbar which says page 3 of 1.
Environment: GWT 2.5 , GXT 3.0.
First, please note that our filters are separate from our grid in that we do not have them tied to the grid header menu - this gives us full control over the widgets but requires that we manage the filters (i.e., make them active or not). We still use these filters with GridFilters so that we can get the proper filtering data sent to the server for our queries.
With that out of the way, we have this issue as well and it manifests in two ways:
To solve this, what we do is when we execute a search or when we reset our filters/grid, we call PagingLoader.setOffset(0) and then call PagingLoader.load() to do the rest of the stuff. This works correctly because we still use GridFilters and we turn our filters on and off accordingly.
- When executing multiple filters (i.e., one after another), and
- When resetting our filters (we want the grid to reset as well).
Basically, on a search, we configure each filter by looking to see if the widget for a filter has been populated with data, if so, we set the value on the filter (something you cannot do by default as the setters are not exposed) and we set the filter to active, otherwise we deactivate the filter.
On a reset, we just deactivate all the filters.
The offset is not reset to zero when you're using the built-in grid header menus to access your filtering because you might keep changing the same field.
Easiest way to fix this in this event would be to add a BeforeLoadEvent via Loader.addBeforeLoadHandler. But this could break pagination (there's an outstanding bug for this, it's not a trivial fix because of the first sentence I wrote above) so in your handler, you'd need to track whether or not the filter criteria has changed. If so, set the offset, if not, don't.
Hope that makes sense. We're having a lively discussion about this on #extgwt if you see this now and want to join.