-
20 May 2008 3:10 PM #1
Populating Trees
Populating Trees
I have a question which might help me to understand the new Loader/Reader/Store/Tree/Binder design a bit better:
I have a TreeModel which I would like to see on 2 different Trees.
The first Tree only shows leafs (a list then), the other Tree all elements.
When using myGWT I used the ContentProvider to define which elements should go on the Tree. Right now, I tried to use a filter but parent elements are always shown if a child is shown.
What would be the correct solution in this case? Is there an equivalent to the former ContentProvider which I have missed?
Cheers
-
20 May 2008 5:56 PM #2
Initial Check State
Initial Check State
Along the same lines .. I used to be able to set the initial checked state of a checkable tree item through the previously available content provider. It doesn't look like the Store/Binder/Tree pattern lets you set the initial state or I'm missing how. What is the correct way to do this?
Thanks!
-
21 May 2008 1:22 AM #3
Jepp, I would need initial checked-state, too...
-
21 May 2008 4:59 AM #4
Another one: How to set checked state of TreeItems in general?
There was a Tree.setChecked(TreeItem, boolean state) in former versions of GXT.
Where do I find it now, or do I have to ask the TreeBinder to retrieve the TreeItem and then set the state?
In general: I think the Binder should have more functionality regarding this stuff (e.g. it should work similar like the ContentProvider before) as it is the link between the model and the Tree...
-
22 May 2008 6:06 AM #5
Initial Check State - workaround
Initial Check State - workaround
As a workaround..
I re-introduced a Checkable interface
And added the following change to TreeBinder to set the initial checked state.Code:public interface Checkable { public boolean isChecked(); public void setChecked(boolean b); }
Code:12a13,14 > import ....Checkable; > 191a194,196 > if (model instanceof Checkable && ((Checkable)model).isChecked()) { > item.setChecked(true); > }
-
22 May 2008 6:23 AM #6
Thnx, copied this workaround

EDIT: No, actually I decided to implement a Synchronizer to adopt the checked state of the model - a bit nasty but it does the job for now:
What is the official answer to these issues? Are there some API changes for next realease concerning TreeBinder?Code:public void synchronize() { int rootCount = model.getChildCount(); for (int i=0; i<rootCount; i++) { AClientModelItem rootChild = (AClientModelItem)model.getChild(i); update(rootChild); } } private void update(AClientModelItem item) { int count = item.getChildCount(); for (int i=0; i<count; i++) { AClientModelItem child = (AClientModelItem)item.getChild(i); update(child); } // Set checked state according to model Component c = binder.findItem(item); if (c instanceof TreeItem) { TreeItem ti = (TreeItem)c; if(ti.isChecked() != item.isRenderedChecked()) { ti.setChecked(item.isRenderedChecked()); } } }
Thanks in advance
-
2 Jun 2008 1:03 AM #7
Is there someone out there who can help us/me with these issues?



Reply With Quote