View Full Version : TreePanel with custom policy for checkable notes

13 Jan 2010, 2:01 AM
Hi All,

I need a TreePanel with a custom policy for checkable nodes. The use case is that some leafs and some non-leafs should be checkable, depending on a rpoperty of the tree node's underlying model element.

To make special leafs non-checkable I overloaded TreePanel.renderChild() and invoked setCheckable depending on the context. But this does not work for non-leafs.

I also played around with onExpand, onCollapse and the CheckNodes.LEAF/CheckNodes.BOTH flags, but after one day of trying I gave up.

I would appreciate any help how I could create a TreePanel that does the following:

All leafs can be checked
All non-leafs cannot be checked, except:
All nodes with model.id=="location" can be checked, even if they have children

Many thanks


13 Jan 2010, 5:49 AM
Found a solution:

Overloaded renderChildren in TreePanel and onCheckChange in TreePanelView.

15 Jan 2010, 8:36 AM
nice that you found a solution. can you pls post your code of solution? thx

one question:

why you dont listen for the event BeforeCheckChange and cancel it if it is not need.

BeforeCheckChange : TreePanelEvent(treePanel, item)
Fires before a node's check state is changed. Listeners can cancel the action by calling BaseEvent.setCancelled(boolean) (http://www.extjs.com/forum/../deploy/gxtdocs/com/extjs/gxt/ui/client/event/BaseEvent.html#setCancelled%28boolean%29).

treePanel : the source tree
item : this
checked : the checked state.