Using TreeItemRenderer and callLater()
A friend of mine needed a Tree Component which had images to the right of text labels and also which would have some items disabled.
The simplest way to go about it was to use a custom ItemRenderer for the Tree component. Here is how I tried to solve it...
- Extend the TreeItemRenderer class to be used for the Renderer.
- Override the createChildren method and add an image component within the renderer.
- Access the listData variable and cast it to TreeListData to know whether a node has further subnodes,etc. and then attach the image.
- Override the set Data function to check if a node needs to be disabled / enabled and accordingly set the style.
- Use the callLater function to set the enabled/ disabled style. The callLater function defers the calling of the given function until the end of the cycle.




1 comments:
Hey aasim,
your blog entry helped and saved lot of time...I needed exactly something like this. I had to put a checkbox for selecting a particular item in the tree and I was able to do that with itemeditor added on top of your code..:)
thanks!
Post a Comment