CellTree expand with CompositeCell - Example or HowTo?!

434 views
Skip to first unread message

guevaradelaserna

unread,
Nov 1, 2011, 7:34:09 AM11/1/11
to google-we...@googlegroups.com
Hi there, 

i want to use the CellTree to show the hierarchy of my data in a tree structure. For beginning took a look at this example  http://code.google.com/intl/de-DE/webtoolkit/doc/latest/DevGuideUiCellWidgets.html#celltree to understand how a CellTree works. This works!!!

But now I want to expand the leafs with further information, like a description or a checkbox. It should look like this http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellTree. Because I'm new to GWT I don't know how to realize it. Could someone give me a hint or a short example?

Thanks Alex

Thomas Broyer

unread,
Nov 1, 2011, 8:43:16 AM11/1/11
to google-we...@googlegroups.com
Why don't you look at the sample's code? (click "source code" on the top bar on the showcase sample; in this one, there are several files, you can switch between them using the drop down next to the "source code" link, and not ethat "example" in the list *is* a "file")

guevaradelaserna

unread,
Nov 1, 2011, 10:30:28 AM11/1/11
to google-we...@googlegroups.com
Hey,

i know the code and tried to understand it, but I didn't get it. I also tried to put it in sample project, but it has to many references to other classes. That was the reason, why I asked, if someone could help me!

Thomas Broyer

unread,
Nov 1, 2011, 11:05:01 AM11/1/11
to google-we...@googlegroups.com
OK, sorry.

So, the thing is to make the NodeInfo for your leaf use a different Cell than the other non-leaf nodes. In the Showcase sample, in ContactTreeViewModel, notice how the getNodeInfo tests the type of the parent value (either 'null' denoting the root node, or a Category node, or a LetterCount node) to choose how to build the DefaultNodeInfo to be returned (children of the root node are categories, rendered using the CategoryCell; children of a category are letter-counts, rendered using a LetterCountCell; etc.)
Finally, the cell used to render individual contacts (leaf nodes), is built in the ContactTreeViewModel's constructor, as a CompositeCell composed of a CheckboxCell and a ContactCell; with the CompositeCell itself using some custom rendering to put each "sub-cell" into a table cell ("td" element within a <table><tr>)

Does it help?

guevaradelaserna

unread,
Nov 2, 2011, 5:59:52 AM11/2/11
to google-we...@googlegroups.com
Yes this was really helpful! Now I understand it in general! Thank you! 

I try to apply it to example 2 of http://code.google.com/intl/de-DE/webtoolkit/doc/latest/DevGuideUiCellWidgets.html#celltree In this example the leafs are added to a list. How I have to modify this function? What's the best way to get started or could you give me a short explanation? 

Thanks in advance
Reply all
Reply to author
Forward
0 new messages