PDA

View Full Version : List not preparing association data when List.grouped = true



sapond
30 Mar 2011, 7:59 AM
Here is the override to fix this:


//This override allows for List component to use asccociations when List.grouped=true
Ext.override(Ext.List, {
style: 'position:relative',
collectData : function() {
if (!this.grouped) {
return Ext.List.superclass.collectData.call(this, records, startIndex);
}

var results = [],
groups = this.store.getGroups(),
ln = groups.length,
children, cln, c,
group, i;

for (i = 0, ln = groups.length; i < ln; i++) {
group = groups[i];
children = group.children;

for (c = 0, cln = children.length; c < cln; c++) {
Ext.apply(children[c].data, this.prepareAssociatedData(children[c]));
children[c] = children[c].data;
}
results.push({
group: group.name,
id: this.getGroupId(group),
items: this.listItemTpl.apply(children)
});
}

return results;
}
});

steve7516
26 Jul 2011, 2:22 PM
I get the following error in my browser--
Uncaught ReferenceError: records is not defined

Is there any specific place I need to put it?

sapond
26 Jul 2011, 2:23 PM
Try this:



Ext.override(Ext.List, {
collectData: function(records, startIndex) {
if (!this.grouped) {
return Ext.List.superclass.collectData.call(this, records, startIndex);
}

var results = [],
groups = this.store.getGroups(),
ln = groups.length,
children, cln, c, group, i;

for (i = 0, ln = groups.length; i < ln; i++) {
group = groups[i];
children = group.children;

for (c = 0, cln = children.length; c < cln; c++) {
Ext.apply(children[c].data, this.prepareAssociatedData(children[c]));
children[c] = children[c].data;
}
results.push({
group: group.name,
id: this.getGroupId(group),
items: this.listItemTpl.apply(children)
});
}
return results;
}
});

steve7516
26 Jul 2011, 2:31 PM
That worked! Thank you so much for the speed.