Firing Checkchange Event On A Tree Node Using Its ID In ExtJs 4.1
I have a TreePanel. Each node in tree is given an ID. On click of a button, I want to fire the checkchange event for node 2.1 (as shown in the below tree). How can I fire checkchan
Solution 1:
To fire the checkchange you need to have the node and if it's checked.
The TreePanel
is using Ext.data.TreeStore
to store it's nodes information (it is in the store
property).
This TreeStore has the getNodeById( id )
method which returns the record node by id.
If you want to get the node from another property, then you need to use the tree
(Ext.data.Tree
) property from store
, which is like a node manager. This has a node record array in the nodeHash
property. You need to iterate this Array and compare the given property manually.
The complete code:
buttonClick: function(button, e, eOpts) {
var treepanel = button.up(...).down('treepanel');
var node = treepanel.getStore().getNodeById(yourIDHere);
// for custom property use this:
/*var nodeHash = treepanel.getStore().tree.nodeHash;
var node;
for (var x in nodeHash) {
if (nodeHash[x].get('customProperty') == customValue) {
node = nodeHash[x];
break;
}
} */
treepanel.fireEvent('checkchange', node, node.get('checked'));
}
Post a Comment for "Firing Checkchange Event On A Tree Node Using Its ID In ExtJs 4.1"