PDA

View Full Version : remove clickability of tree nodes



niteshgoel
18 Feb 2013, 9:33 PM
Hi,

How can i remove the click of the tree nodes (i.e i dont want them to be clickable) and selectively apply clickability on tree nodes.


Thanks.

slemmon
18 Feb 2013, 9:55 PM
Use treepanel's beforeselect event (see example below). In the beforeselect handler you can evaluate the record to see if you want it to be selectable. In this example I return true if the record is not a leaf.



var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [
{ text: "detention", leaf: true },
{ text: "homework", expanded: true, children: [
{ text: "book report", leaf: true },
{ text: "alegrbra", leaf: true}
] },
{ text: "buy lottery tickets", leaf: true }
]
}
});


Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 200,
height: 150,
store: store,
rootVisible: false,
renderTo: Ext.getBody()
, listeners: {
beforeselect: function (selModel, record) {
return !record.isLeaf();
}
}
});