PDA

View Full Version : Reset List scroll position to top



rickyclegg
21 Mar 2011, 2:21 AM
I have an Ext.List that is binded to a data store. I regularly change the data in the store. if there is a lot less items in the list. it retains the previous scroll position so you cannot see anything.

So whenever I change the data that is displayed. I wish to set the scroll position of the list back to the top. But I cannot find a scroller property on the list of the equivalent.

Any help would be great.

BenMajor
21 Mar 2011, 2:24 AM
The scroller object belongs to the Panel to which the List belongs. As a result, after updating your DataStore, try calling the following method:


PanelRef.scroller.scrollTo({ x: 0, y: 0 })

Obviously updating PanelRef to represent the container for the list.

HTH,
Ben.

rickyclegg
21 Mar 2011, 2:54 AM
I have tried adding PanelRef.scroller.scrollTo({ x: 0, y: 0 }) to the code. It always says that the "scroller" property is undefined. But I know that is is rendered as I can see it on screen.

Any ideas why my list doesn't have a scroller property?

rickyclegg
21 Mar 2011, 2:56 AM
my exact line is.

this.configuratorSelectionList.scroller.scrollTo({ x: 0, y: 0 });

So I have changed out panel ref and and everything. But when I pause in Firebug scroller is undefined.

Kurt001
21 Mar 2011, 3:30 AM
Hi

I had the same problem and until no one comes up with a better idea, here is my solution:

list.doComponentLayout();

Best Kurt

rickyclegg
21 Mar 2011, 3:32 AM
Thank you for the replies. Like all great bugs it was my own fault. The list was always set to full size and was a child of a panel with a toolbar that did all the scrolling. So the scroller property was on the panel object. So I simply reset the scrolling on that item.

Thanks

MPeg
22 Jan 2012, 1:30 AM
Hi, here is another thread in this forum about this issue:
http://www.sencha.com/forum/showthread.php?110053-Reset-list-scroll-position-to-top&p=718816#post718816

Here you can find a little how-to that reassume proposed solutions:
http://goo.gl/f7oVY

Bye!
MPeg

yerajeff
24 Mar 2012, 1:10 AM
Here is how I solved the problem just incase anyone views this thread:


Ext.getCmp('componentId').getScrollable()._scroller.scrollTo(0,0);