Ext.ux.AccordionList
Ext.ux.AccordionList copied to clipboard
addrecords handler is not correct - fix posted here
I don't think the "addrecords" event handler is correct. fixTreeStoreSortOrder just plain does not work when the inserted record is NOT the first child.
This seems to work in Sencha Touch 2.3.1 to rebuild the "all" list and the items "list".
store.on('addrecords', function (store, records) {
// fix sort order if we add children to a already loaded treestore
var all = [];
var expanded = [];
addNodes(all, store.getRoot());
addExpanded(expanded, store.getRoot());
store.getData().all = all;
store.getData().items = expanded;
function addNodes(arr, node) {
var childNodes = node.childNodes;
for (var i = 0; i < childNodes.length; i++) {
arr.push(childNodes[i]);
addNodes(arr, childNodes[i]);
}
}
function addExpanded(arr, node) {
var childNodes = node.childNodes;
for (var i = 0; i < childNodes.length; i++) {
arr.push(childNodes[i]);
if (childNodes[i].get("expanded")) {
addExpanded(arr, childNodes[i]);
}
}
}
});
Should do the same for "removerecord" events.
After adding all the records, I also had to do a
store.updateNode(store.getRoot())