I'm using the tree control in GWT. I have a custom widget that I add as a TreeItem:
Tree testTree = new Tree();
testTree.addItem(myWidget);
I would like to retrieve myWidget instance on the node opening event. Is it possible ? Does anybody knows which event should I be using ?
I tried the openHandler<TreeItem> but what I retrieve is the... tree item.
In almost every case in which you're using GWT's Tree, you really want to be using the GWT Incubator's FastTree, which has an addBeforeOpenHandler() method, which takes a BeforeOpenHandler<FastTreeItem> which passes a BeforeOpenEvent to onBeforeOpen() making available the source of the event (that was a mouthful...)
Long story short, FastTree > Tree, and you want to use addBeforeOpenHandler() on the FastTree itself.
To add widgets to your tree (instead of just FastTreeItems) you can add your widget to the enclosing FastTreeItem, or just subclass FastTreeItem to do what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With