PDA

View Full Version : Check all child nodes of a Ext.tree.AsyncTreeNode



hbopuri
8 Jan 2015, 9:16 AM
I am trying to check all child nodes of a node if this is checked.
Added a listener


tree.addListener('expandnode', this.onTreeNodeExpand, this);

Function




onTreeNodeExpand: function (node) {
if (node.hasChildNodes()) {
node.eachChild(function (n) {
var checked = n.parentNode.ui.isChecked();
if (checked != undefined && checked) { n.getUI().toggleCheck(checked);
}
});
}
}


Since I have Async tree node, all child records will be loaded on demand and first time when the node is expanded I get false for this statement

if (node.hasChildNodes())

// returns false

It think "expandnode" event is called same time while Async is in progress.
How can I capture a event where after async data is loaded, check if this node is checked and set all child nodes to checked?

lumberjack
12 Jan 2015, 1:48 PM
Have you tried the Ext.tree.AsyncTreeNode.load (http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.tree.AsyncTreeNode-event-load) event?

Regards,
Brian