PDA

View Full Version : Infinite Grid - How to scroll to the exact position.



alone_wolf
18 Jun 2013, 6:26 AM
How to scroll to the exact position of a specific record in a Infinite Grid?

I tried using scrollTo() with the number of rows multiplied by the row size, sometimes it works just right, other times it gets near the correct item but not exactly, and other times it misses them entirely.


grid.getView().getEl().scrollTo("top", row_count*row_size);

I also tried using scrollIntoView() but only works when already near the row, I think that has to be in the buffer to Ext.get() work.


Ext.get(row_id_str).scrollIntoView(grid.getView().getEl().id);

Is there a way to scroll to the exact position without being the approximate amount as with scrollTo()?

tvanzoelen
18 Jun 2013, 6:38 AM
What do you mean by Infinite grid? Do you use the BufferedRenderer?

If you do, that plugin has a function
scrollTo

alone_wolf
18 Jun 2013, 6:51 AM
tvanzoelen, I used scrollTo(), but like I said, it's not precise.


I tried using scrollTo() with the number of rows multiplied by the row size, sometimes it works just right, other times it gets near the correct item but not exactly, and other times it misses them entirely.

tvanzoelen
18 Jun 2013, 6:57 AM
I asked if you used the BufferedRenderer. Do you?

The plugin has its own function scrollTo.

The you do something like



var plugin = gridPanel.getPlugin('buffered');

if (plugin) {
plugin.scrollTo(record.index);
}


don;t forget then to assign the plugin an id so you can get it with getPlugin(). Here I used 'buffered'.

Else view.focusRow, should also do the trick.

alone_wolf
25 Jun 2013, 1:07 PM
Found a way.

var grid = Ext.create('Ext.grid.Panel', {
...
verticalScroller: {
xtype: 'paginggridscroller'
},
...
}
...
grid.verticalScroller.scrollTo(idx);