-
11 Mar 2012 8:50 PM #1
Answered: How to use scrollToEnd ?
Answered: How to use scrollToEnd ?
Hi frnz ,
I'm using
to get scroller of my panel 'pan'.Code:var scroller = pan.getScrollable().getScroller();
I want to programatically scroll to bottom of the page, I can use
scrollToEnd( Object animation ) for this ryt?
The question is what is how to do that?
I tried
Code:pan.scrollToEnd(scroller);
Code:scroller.scrollToEnd(this);
None of them works , I get error:Code:scroller.scrollToEnd(pan);
Object [object Object] has no method 'scrollToEnd'
Please tell me am i missing something?
Thanks,
mrunal
-
Best Answer Posted by mitchellsimoens
Here is a little example:
Code:new Ext.Container({ fullscreen : true, scrollable : 'vertical', items : [ { xtype : 'toolbar', docked : 'top', items : [ { text : 'Scroll to End', handler : function(btn) { var cnt = btn.up('container[fullscreen]'), scroller = cnt.getScrollable().getScroller(); scroller.scrollToEnd(true); } }, { text : 'Scroll to Top', handler : function(btn) { var cnt = btn.up('container[fullscreen]'), scroller = cnt.getScrollable().getScroller(); scroller.scrollToTop(true); } } ] }, { height : 200, html : 'One' }, { height : 200, html : 'Two' }, { height : 200, html : 'Three' }, { height : 200, html : 'Four' }, { height : 200, html : 'Five' }, { height : 200, html : 'Six' }, { height : 200, html : 'Seven' }, { height : 200, html : 'Eight' }, { height : 200, html : 'Nine' }, { height : 200, html : 'Ten' } ] });
-
12 Mar 2012 4:40 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,608
- Vote Rating
- 435
- Answers
- 3102
Here is a little example:
Code:new Ext.Container({ fullscreen : true, scrollable : 'vertical', items : [ { xtype : 'toolbar', docked : 'top', items : [ { text : 'Scroll to End', handler : function(btn) { var cnt = btn.up('container[fullscreen]'), scroller = cnt.getScrollable().getScroller(); scroller.scrollToEnd(true); } }, { text : 'Scroll to Top', handler : function(btn) { var cnt = btn.up('container[fullscreen]'), scroller = cnt.getScrollable().getScroller(); scroller.scrollToTop(true); } } ] }, { height : 200, html : 'One' }, { height : 200, html : 'Two' }, { height : 200, html : 'Three' }, { height : 200, html : 'Four' }, { height : 200, html : 'Five' }, { height : 200, html : 'Six' }, { height : 200, html : 'Seven' }, { height : 200, html : 'Eight' }, { height : 200, html : 'Nine' }, { height : 200, html : 'Ten' } ] });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
14 Nov 2012 8:43 PM #3
if the scrollble direction is horizontal, I tried and no use.
-
28 Dec 2012 10:32 AM #4
Hey Mitchell - while the above code executes without error, I'm having a problem with long lists that I'm hoping you can help with. The idea is that when I show the list, I load the store, when the store is loaded, I want to scroll to the bottom. (It's a chat log with the newest chats at the bottom).
If I call "scrollToEnd" as the callback of the store.load(), it doesn't do anything (I'm assuming because the list hasn't been updated yet). If I set an absurdly long timeout (for testing's sake) and then call scrollToEnd, it scrolls about 75% of the way to the bottom. I've found two ways to "fix" this, though neither are actually going to work in practice:
1) in my console, if I call refresh(), then scrollToEnd(), refresh(), scrollToEnd() a few times, it makes its way there.
2) if the user has scrolled on their own, then I call scrollToEnd(), it works *perfectly*.
I found reference to this in an old ticket and the solution was to call updateBoundary, but that has been replaced with "refresh" and lead to my first hack (http://stackoverflow.com/questions/6...lly-just-befor)
As vague as this is, I'm at a standstill, so I'm hoping you can help point me in the right direction.


Reply With Quote