dgrid
dgrid copied to clipboard
OnDemandGrid/List provide no way to start at a specific scroll position
This is another feature request.
The OnDemandList and Grid provide no way to specify a starting scroll position. This can be accomplished by loading the grid and set the scroll position manually, but this will cause unnecessary service calls.
This is a deal breaker for us. We would like to use dgrid for displaying documents and just about any data that is paged. We have a gadget system that allows switching views (gadget sets), and when a view is restored the gadgets display "exactly" (same top page/row) what was previously displayed - and not start back at page 1.
Is it possible to get feedback on if and when this might be implemented? Thanks.
Keep in mind that the total number of results is also unknown until the first query returns, so in reality an initial query needs to be performed anyway, for the list/grid to know how much virtual space to occupy (based on the total, and the average height of each row in the first set of results).
Recent versions of dgrid include a dgrid-refresh-complete
event which fires when the first results finish rendering, so you could tell the grid to scroll once that event fires. Basically something along these lines:
- When you're going to switch views, call
grid.getScrollPosition()
to receive an object withx
andy
properties indicating the current scroll position - When a view loads, hook up a one-time handler on the
dgrid-refresh-complete
event (usingon.once
fromdojo/on
) - Inside that handler, call
grid.scrollTo()
passing the object previously received fromgetScrollPosition
@kfranqueiro I know it's old, but the proposed solution will not work with OnDemandList in case the rows have variable heights. Currently (with dgrid 1.2.1), when I try to scrollTo the stored position, it can happen that another scrollTo is called from inside (see keepScrollTo and its influence in the _processScroll function).
When I have a long grid, it often happens that I can see properly restored position and then a sudden jump little bit elsewhere :-(