ExtJS4 tree panel issue
We are using treepanel in our application. It is working fine. But if we select the parent node, t开发者_StackOverflow中文版hen the child nodes in that parent are not selected. How do we select the child nodes when we select the parent node?
Is there any method available in ExtJS4?
You have to respond on the itemclick
event and select all nodes below the clicked node. If you only want to select the immediate children of the clicked node, exchange cascadeBy()
with eachChild()
.
tree.on("itemclick", function(view, record) {
var selModel = tree.getSelectionModel();
record.cascadeBy(function(r) {
selModel.select(r, true);
});
});
The Ext.tree.View class has a select function.
select( Ext.data.Model/Index records, Boolean keepExisting, Boolean suppressEvent )
On select you can fetch the underlaying nodes and call this, sending on your selected node's children (their records)
Remember to specify second parameter as false, so you don't end up recursive
精彩评论