PDA

View Full Version : Reach the end of a list



dbottillo
15 Nov 2010, 2:59 AM
Hi,

before sencha 0.99 to reach the end of a list while user scrolling, i used this code:

list.scroller.on('scroll', function(scroller, offsets) {
var distanceToEnd = scroller.size.height - offsets.y - scroller.parentSize.height;
if (distanceToEnd < 300) {
numPage=numPage+1;
MyList.store.proxy.extraParams.page=numPage;
MyList.store.load();
}
}, this, {buffer: 300});

but now scroller.parentSize.height is null
i found that now there is scroller.containerBox.height, i try to change parentSize.height with containerBox.height
but now if i scroll down to list my code doesn't do anything (it seems that distanceToEnd is never less then 300)

it's change something? how can i reach the end of a list with sencha > 0.99?

my complete code is:

Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,
onReady: function() {

var numPage = 1;

Ext.regModel('Model', {
fields: [{
name: 'name',
type: 'string'
}]
});

var storeList = new Ext.data.Store({
autoLoad: true,
model: 'Model',
proxy: {
url: 'path_to.json',
type: 'scripttag',
noCache: 'false',
callbackParam: 'idSession',
extraParams: {
rpp: 35,
page: 1,
},
timeout: '15000',
reader: {
root: 'results'
}
}
});

var MyList = new Ext.List({
flex: 1,
singleSelect: true,
itemSelector: 'div#offer',
itemTpl: [
'<div id="offer">',
'{name} </div>',
],
store: storeList,
listeners:{
afterrender: function(){
this.scroller.on('scroll', function(scroller, offsets) {
var distanceToEnd = scroller.size.height - offsets.y - scroller.containerBox.height;
if (distanceToEnd < 300) {
numPage=numPage+1;
MyList.store.proxy.extraParams.page=numPage;
MyList.store.load();
}
}, this, {buffer: 300});
}
}
});



var MyApp = new Ext.Container({
fullscreen: true,
layout: {
type: 'vbox',
align: 'stretch'
},
items: [MyList]
}).show();

}});

evant
15 Nov 2010, 7:25 AM
Container getBox should provide similar details.