PDA

View Full Version : scroll list to the top on refresh



wakatanka
18 Jul 2010, 12:44 AM
Hi, i've a list dynamically populated from an ajax call and it work fine.
There are only six rows visible, so when i have more than 6 i can scroll to the bottom , and here
is the problem.
If i scroll to the bottom of 20 rows, when i refresh the list with other data (3 rows for example) the
list remain to the bottom and i don't see anything until i manually scroll to the top.
Is there a way to avoid this?

thanks so much

robertj98
18 Jul 2010, 7:17 AM
After you do the code to refresh the list or store you can use


timeline.scroller.scrollTo({x: 0, y: 0}, true); // scroll to the top

where timeline is the id of the list.

wakatanka
19 Jul 2010, 4:09 AM
Thank you Robert, it works flawless.

FlorianArndt
9 Aug 2010, 2:03 AM
Hello there,

when using Sencha Touch 0.93beta I get the error that the property scroller is undefined for both list and panel.
What am I missing?

Thanks in advance and for the great community support
Florian

evant
9 Aug 2010, 4:25 AM
Probably either

a) You haven't setup scrolling on your panel
b) The panel isn't rendered yet

FlorianArndt
9 Aug 2010, 4:33 AM
a) scrolling is set to 'vertical'
b) the AJAX request triggering the alert is made well after the initial loading of the tabpanel I use
Can you give me a simple example where is is used in a small demo application?

evant
9 Aug 2010, 4:36 AM
Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,

onReady: function() {
var html = [];
for(var i = 0; i < 500; ++i){
html.push('line ' + i);
}

var p = new Ext.Panel({
fullscreen: true,
scroll: 'vertical',
html: html.join('<br />')
});
p.scroller.scrollTo({
x: 0,
y: 1000
}, true);
}
});

FlorianArndt
9 Aug 2010, 4:49 AM
My mistake was somewhere else, but you still helped me figure it. Cheers!