Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrolling programatically in dGrid. #360

Closed
waseemvnb opened this issue Dec 3, 2012 · 1 comment
Closed

Scrolling programatically in dGrid. #360

waseemvnb opened this issue Dec 3, 2012 · 1 comment

Comments

@waseemvnb
Copy link

Below is the code where I wanted to scroll dynamically by giving the RowNo (Id).

Code: grid.bodyNode.scrollTop = grid.row(rowNo).element.offsetTop

I get an exception for the above line, only when the dgrid has not loaded the rows so it returns a Row object in which 'element' is undefined.

However when I have 1000 rows in dGrid then if the first 100 rows are loaded then above code scrolls fine for the rows which are already loaded, but for the subsequent rows which are not loaded into view throws exception. (cannot read property 'offset' of null ) (I think this is because the element for the row is undefined since it is not loaded.)

Any idead on how do I load a row programatically so that the above code auto scrolling works.?

@kfranqueiro
Copy link
Contributor

Firstly, there is a scrollTo method on dgrid instances, which you can pass an object with x or y properties to scroll in a platform-agnostic manner (since scrolling is handled differently for touch devices).

Regarding the issue of rows that have not yet been rendered, well, yes, that's a bit of a tricky situation, since the rows haven't been rendered yet, and it would generally be a bad idea to pre-render all of the rows just for the sake of knowing where to scroll. What you can do, particularly if your rows tend to be uniform height, is make an educated guess as to what the scroll position of the desired row would be (by multiplying # of rows to scroll by the known height of one of the rendered rows), and using that as a y value passed to scrollTo. Once the scroll is performed, the items for that position within the grid will be requested.

For future reference, support questions like this are better posed to the #dojo IRC channel or dojo-interest mailing list to get a wider audience than the issue tracker, which is primarily for bugs or enhancements. See the Getting Support section of the README for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants