SharpCoder
SharpCoder

Reputation: 19163

Disabling selection of a node in ExtJS tree panel if the node is not a leaf node

I am using ExtJs 4.1 TreePanel control & want to disable selection of a node if that node is not a leaf node. Do we have any property out of the box to achieve this?

So If the node is not a leaf node, disable selection and if user click on that node, system should not fire any event (itemClick or select etc).

Thank you

Upvotes: 1

Views: 4998

Answers (1)

existdissolve
existdissolve

Reputation: 3114

There's no property, but you could always key on the beforeitemclick or beforeselect event (or both, depending on what you need to do). Add a handler for this event, check if the clicked node is a leaf, and if it's not, simply return false. That will halt the default behavior and effectively disable the non-leaf nodes.

http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.tree.Panel-event-beforeselect

Upvotes: 4

Related Questions