PDA

View Full Version : Scrolling to on scrollend



TDeBailleul
21 Nov 2011, 8:04 AM
Hi everyone,

What I want is simple but I can't make it work. I have an Ext.List with 5 items in it. When I scroll to the end of that list, it load 5 more items and so on. After loading these new items, I want to scroll down to these news items.

I tried the next code but it does not work. The alert return 0.
But then, when I scroll the list again (not even to the end) it scrolls to these news items.



this.actuGrid = new Ext.List({
store: app.stores.actualites,
grouped : false,
itemTpl: app.templates.actualiteList,
listeners: {
scroller: {
scrollend: function(scroller, offset){
var currentNumberOfNews = parseInt(app.stores.actualites.getCount());
var nextNumberOfNews = currentNumberOfNews+app.newsPerLoad;
var newYPosition = currentNumberOfNews*70;
app.stores.actualites.load(
new Ext.data.Operation({
start:0,
limit:nextNumberOfNews
})
);
scroller.scrollTo({x:0,y:newYPosition});
alert(offset.y);

}
}
}
});


I hope somebody can tell me what is wrong with the code or what the problem is.

Thank you

mitchellsimoens
21 Nov 2011, 10:36 AM
Have you tried just using the ListPagingPlugin that is included in the framework?

TDeBailleul
21 Nov 2011, 11:56 AM
No, I didn't try it yet because I wanted to use my own code. Plus I don't see what I'm doing wrong here, and I would like to understand why it doesn't work and not 'skip the problem'.

But if nobody finds out what the problem is here, I'll give it a shot.

Thanks

mitchellsimoens
21 Nov 2011, 12:31 PM
Look at the source to see how it was achieved.