PDA

View Full Version : Ext.List Scroll event on empty grouped list errors out



asenec4
17 May 2011, 2:43 PM
Try this simple example

Ext.setup({
onReady: function(){
var a = new Ext.List({
fullscreen: true,
grouped: true,
emptyText: "it's empty!",
deferEmptyText: false,
store: new Ext.data.Store({
model: 'Contact',
data: []
}),
itemTpl: '<div class="contact"><strong>{firstName}</strong> {lastName}</div>'
});
}
});

Now try to scroll or interact in any way with the list.
It errors out with sencha-touch-debug.js:23478 (http://afsweb.ms.com/ms/dev/ria/webaurora/dev/install/common/ria/sencha-touch/1.1.0/install/common/sencha-touch-debug.js)Uncaught TypeError: Cannot read property 'offset' of undefined

Seems the onScroll listener is attached in initEvents to all grouped list but onScroll doesn't factor in empty lists.

Surjikal
2 Aug 2011, 11:13 AM
Bump; this is still happening.

gardenofwine
10 Oct 2011, 12:04 PM
I have two workarounds:
1) make the list disappear if its empty likewise:


Ext.setup({
onReady: function(){
var a = new Ext.List({
fullscreen: true,
grouped: true,
emptyText: "it's empty!",
deferEmptyText: false,
store: new Ext.data.Store({
model: 'Contact',
listeners: { afterrender: function(){
if (this.store.getCount() == 0) {
this.setVisible(false);
}
else {
this.setVisible(true);
}
},
data: []
}),
itemTpl: '<div class="contact"><strong>{firstName}</strong> {lastName}</div>'
});
}
});

2) make the list unscrollable if its empty


Ext.setup({
onReady: function(){
var a = new Ext.List({
fullscreen: true,
grouped: true,
emptyText: "it's empty!",
deferEmptyText: false,
store: new Ext.data.Store({
model: 'Contact',
listeners: { beforerender: function(){
if (this.store.getCount() == 0) {
this.setScrollable(false);
}
else {
this.setScrollable(true);
}
},
data: []
}),
itemTpl: '<div class="contact"><strong>{firstName}</strong> {lastName}</div>'
});
}
});