PDA

View Full Version : Reset list scroll position to top



jacstofberg
16 Sep 2010, 7:52 PM
Hi there,

This may seem a silly question, but I just can't figure out how to reset a list's scroll position back to zero (top). I reload my list store dynamically and the new store often contains less elements than the previous one. The result is that if the first (longer) list happened to be scrolled a fair amount to the bottom, the new (shorter) list's elements cannot be seen upon loading the new store unless one scrolls all the way to the top by hand.

Your help is much appreciated.

Kind regards,
Jac

evant
16 Sep 2010, 7:58 PM
list.scroller.scrollTo({
x: 0,
y: 0
});

jacstofberg
16 Sep 2010, 8:02 PM
Thank you for the prompt reply:) It works like a charm.

Cheers,
Jac

MPeg
4 Sep 2011, 7:39 AM
Hi, can you paste an example code starting from a List istantiation to show how and where to use the scrollTo() method? Thanks!

PS: I wrote a little entry in my blog to document an issue to List scrolling fixed whit the help of this thread! http://goo.gl/f7oVY. (http://goo.gl/f7oVY)

hrishikeshp19
5 Dec 2011, 2:53 PM
scroller is not a part of list, so list.scroller does not work. Please help

grnadav
2 Jan 2012, 2:13 AM
scroller is not a part of list, so list.scroller does not work. Please help

it exists only after rendering
do


if (list.rendered) { list.scroller.scrollTo({x:0, y:0});
}


working on Secha Touch 1.1.1

stereodinamico
21 Jan 2012, 4:49 PM
Works great for me....Thanks!

openxtiger
31 Jan 2012, 10:22 PM
Ext.override(Ext.DataView,{
refresh: function() {
if (!this.rendered) {
return;
}


this.fireEvent('beforerefresh', this);
var el = this.getTargetEl(),
records = this.store.getRange();
el.update('');
if (records.length < 1) {
if (!this.deferEmptyText || this.hasSkippedEmptyText) {
el.update(this.emptyText);
}
this.all.clear();
} else {
this.tpl.overwrite(el, this.collectData(records, 0));
this.all.fill(Ext.query(this.itemSelector, el.dom));
this.updateIndexes(0);
}
this.hasSkippedEmptyText = true;


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


this.fireEvent('refresh', this);
}
});