dgrid icon indicating copy to clipboard operation
dgrid copied to clipboard

OnDemandGrid/List provide no way to start at a specific scroll position

Open khous opened this issue 11 years ago • 3 comments

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.

khous avatar Mar 04 '13 17:03 khous

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.

bradmop avatar Jul 09 '13 23:07 bradmop

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:

  1. When you're going to switch views, call grid.getScrollPosition() to receive an object with x and y properties indicating the current scroll position
  2. When a view loads, hook up a one-time handler on the dgrid-refresh-complete event (using on.once from dojo/on)
  3. Inside that handler, call grid.scrollTo() passing the object previously received from getScrollPosition

kfranqueiro avatar Jul 09 '13 23:07 kfranqueiro

@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 :-(

Mi-La avatar Jan 31 '18 15:01 Mi-La