View Full Version : Can't get scroller of grid panel

1 Oct 2012, 8:54 AM
Hello! I am trying to get the scroller of my gridpanel in order to subscribe to its events later on. Ultimately I would like to implement something like what has been reproduced below. Where I am having problems is that I cannot find the scroller object inside in my gridpanel. Does this object no longer exist in a grid panel / is there perhaps another way I can subscribe to the 'scrollend' event on a grid panel?

What I have tried: (inside the constructor of the class which extends 'Ext.grid.Panel' & 'me' being the gridpanel itself.) :

var scroller = me.getScrollable().getScroller();

var scroller = me.view.getScrollable().getScroller();

^ these obviously don't work because those objects don't exist. Or at least I can't find them.

I am able to get generic scroll events through the following:

me.view.on('bodyscoll', function (t, s)

This doesn't help me because I am trying to subscribe to events that are specific to when the scroller reaches the bottom.

What I would like to be able to do:

var scroller = list.getScrollable().getScroller();

and later:

scroller.on('scrollend', function(scroller, x, y) {
if (y >= scroller.maxPosition.y) {
//you have scrolled to the end of the list
}, list);

Any help would be appreciated! Thanks!

1 Oct 2012, 10:38 AM
You can get the position using:



1 Oct 2012, 10:48 AM
Thanks for the reply!

So yes, if I use
me.view.on('bodyscroll' and then find the value of scrollTop it gives me the position of the scroller. However this value is useless because I have nothing to relate it to. Every time the grid panel changes size then the scale of this number changes. What would be best is if there was a value that behaved the same as scrollTop but applied to the bottom of the panel (value would be 0 when scrolled to the bottom). I would be able to put a solution together if the max value of scrollTop was known before handling the event.

1 Oct 2012, 11:07 AM
I was able to implement a 'ScrollBottom' by using the following:

console.log("ScrollY: " + (me.getView().el.dom.scrollHeight - me.getView().el.dom.scrollTop - me.getView().el.dom.offsetHeight));

Ultimate value will be 0 when the scroller reaches the bottom. Thanks for the help!