GWT CellTree : DataBinding, Sorting & filtering

705 views
Skip to first unread message

vaibhav bhalke

unread,
Apr 5, 2012, 2:54:03 AM4/5/12
to google-we...@googlegroups.com
Hi,

I want to  render large tree dynamically so I selected CellTree widget.
I also want  to know How CellTree widget supports DataBinding, Sorting & filtering etc.. ?


--
Best Regards,
Vaibhav

Thomas Broyer

unread,
Apr 5, 2012, 4:13:54 AM4/5/12
to google-we...@googlegroups.com

On Thursday, April 5, 2012 8:54:03 AM UTC+2, vaibhav gwt wrote:
I want to  render large tree dynamically so I selected CellTree widget.
I also want  to know How CellTree widget supports DataBinding,

CellTree, like all Cell widgets, is *based* on databinding (unless you don't have the same definition for databinding as me)
 
Sorting & filtering etc.. ?

It doesn't support those features, but your model (TreeViewModel) can (most likely using a decorator pattern around you real TreeViewModel). The hardest part is to fire the appropriate events so that the CellTree re-renders your tree with the updated model.
I've implemented a live outline of a rich-text editor (as soon as you add/remove a heading, the outline tree updates; same if you change the heading level; and if you type in the heading, the corresponding tree item updates with the new heading text). In my case, I used ListDataProviders within DefaultTreeNodes, and to update the tree I simply replace the whole list (ListDataProvider#setList). When an element has changed –but not the structure of the list– (e.g. when a heading's text changes), then I get the parent node's children list and call setList with the same value, it'll redraw the children of the parent node, so will redraw our updated node (along with all its sibling; it could probably be optimized, but nobody reported any performance issue yet; we also do that because our list is unmodifiable, so we cannot simply set() the item on the list to update that one heading).

vaibhav gwt

unread,
Apr 5, 2012, 6:10:42 AM4/5/12
to Google Web Toolkit
@ Data_Binding : From server side we are passing xml to client side.
Is there any way to bind that xml data to CellTree so that all data
populated/render in CellTree (In Tree format)
like.. In smartGwt http://www.smartclient.com/smartgwt/showcase/#featured_tree_grid
==> Source code ==>see EmployeeXmlDS.java # Created data source set to
TreeGrid
#1 Create dataSource : specify dataUrl (data in xml format) &
setRecordXPath etc.. and set created DataSource in TreeGrid

BUT I dont want to use SmartGwt ( :( Its not free) . I want to use
GWT.

In GWT,: How to populate a CellTree with xml data which is coming
from server side
From server side we are passing xml to client side. Is there any way
to bind that xml data to CellTree so that all data populated/render in
CellTree (In Tree format)

@ Sorting ?

Or Is there any Tree widgets (from Open source) which provides
Sorting, Filtering, DataBinding

On Apr 5, 1:13 pm, Thomas Broyer <t.bro...@gmail.com> wrote:
> On Thursday, April 5, 2012 8:54:03 AM UTC+2, vaibhav gwt wrote:
>
> > I want to  render large tree dynamically so I selected CellTree widget.
> > I also want  to know How CellTree widget supports DataBinding,
>
> CellTree, like all Cell widgets, is *based* on databinding (unless you
> don't have the same definition for databinding as me)
>
> > Sorting & filtering etc.. ?
>
> It doesn't support those features, but your model (TreeViewModel) can (most
> likely using a *decorator* pattern around you *real* TreeViewModel). The

Thomas Broyer

unread,
Apr 5, 2012, 6:25:28 AM4/5/12
to google-we...@googlegroups.com


On Thursday, April 5, 2012 12:10:42 PM UTC+2, vaibhav gwt wrote:
@ Data_Binding : From server side we are passing xml to client side.
Is there any way to bind that xml data to CellTree so that all data
populated/render in CellTree (In Tree format)
like.. In smartGwt http://www.smartclient.com/smartgwt/showcase/#featured_tree_grid
==> Source code ==>see EmployeeXmlDS.java # Created data source set to
TreeGrid
#1 Create dataSource : specify dataUrl (data in xml format) &
setRecordXPath etc.. and set created DataSource in TreeGrid

BUT I dont want to use SmartGwt ( :( Its not free) . I want to use
GWT.

In GWT,:  How to populate a CellTree with xml data which is coming
from server side
From server side we are passing xml to client side. Is there any way
to bind that xml data to CellTree so that all data populated/render in
CellTree (In Tree format)

You have to build a TreeViewModel around your XML data. 

vaibhav gwt

unread,
Apr 6, 2012, 5:27:37 AM4/6/12
to Google Web Toolkit

How to build TreeViewModel using following sample xml ?

Sample xml :
<List>
<employee>
<EmployeeId>111</EmployeeId>
<ReportsTo>1</ReportsTo>
<Name>Thomas</Name>
</employee>
<employee>
<EmployeeId>222</EmployeeId>
<ReportsTo>111</ReportsTo>
<Name>Vaibhav</Name>
</employee>
</List>


public class MyTreeViewModel implements TreeViewModel {
@Override
public <T> NodeInfo<?> getNodeInfo(T value) {
// ????
return null;
}

@Override
public boolean isLeaf(Object value) {
/// ????
return false;
}
}

How to perform sorting & filtering based on MyTreeViewModel ?
Reply all
Reply to author
Forward
0 new messages