wdunn
29 Jun 2012, 11:45 AM
I have a treestore loaded. I want to loop through each immediate child node ( depth level 1). If the child node matches the selection criteria then I want to copy the node and all its children and add them to a new store.
onTreestoreLoad: function(treestore, node, records, successful, options) {
var seq = 1;
for(seq; seq <= treestore.getProxy().reader.jsonData.count; seq++){
var store = Ext.create('Ext.data.TreeStore', {
model: 'MyApp.model.compTree',
storeId: 'compTreeStore' + seq
});
var root = store.setRootNode();
node.eachChild(function(node){
console.log(node);
if (node.data.sequence === seq) {
root.appendChild(node.copy(null, true));
}
});
}
}
The issue it that it sets all the child node id's to MyApp.model.compTree-true and the internal id to "true".
Any help or a simple use case of copying a tree node recursively and applying to another store would be appreciated.
onTreestoreLoad: function(treestore, node, records, successful, options) {
var seq = 1;
for(seq; seq <= treestore.getProxy().reader.jsonData.count; seq++){
var store = Ext.create('Ext.data.TreeStore', {
model: 'MyApp.model.compTree',
storeId: 'compTreeStore' + seq
});
var root = store.setRootNode();
node.eachChild(function(node){
console.log(node);
if (node.data.sequence === seq) {
root.appendChild(node.copy(null, true));
}
});
}
}
The issue it that it sets all the child node id's to MyApp.model.compTree-true and the internal id to "true".
Any help or a simple use case of copying a tree node recursively and applying to another store would be appreciated.