PDA

View Full Version : I want to disable the selected node of a tree...how to do it?



sankarbaluz
31 Aug 2011, 12:54 AM
I want to disable the selected node of a tree...how to do it?Please provide me a solution



tree.getSelectionModel().on('select', function(sm, record) { });

or


treePanel = Ext.create('Ext.tree.Panel', {
id:'navTree',
store: store,
rootVisible: false,
useArrows: true,
frame: true,
region:'west',
width: 250,
autoHeight:true,
scope:this,
// height: 80,
listeners: {
itemclick : function(view,rec,item,index,eventObj) {


}
}

});

skirtle
31 Aug 2011, 9:08 AM
Not sure there's a trivial way to do this but it shouldn't be too hard. Depends to some extent on what you mean by disable.

I think I'd approach it like this...


Add a disabled field to the treestore to keep track of which nodes are disabled.
Add a beforeselect listener that will stop disabled nodes being selected.
Add a beforeexpand listener to stop disabled nodes being expanded.
When a node is disabled, set the disabled field to true and apply a CSS class for whatever styling you want to apply.