I\'m using GWT 2.1\'s CellBrowser with a custom TreeViewModel
. The TreeViewModel in turn uses an AsyncDataProvider
to fetch data dynamically. This all
I don't understand why affablebloke's answer is marked as "correct" and upvoted so much!?
Caffeine Coma asked about updating a Cell Browser and not a Cell Table, that are totally different things!
For me, the following trick worked:
I define the DataProvider
s outside of the TreeViewModel
and pass them as an argument to the constructor. In my case they provide empty data structures at the beginning.
Now you have a reference to the DataProvider
s from "outside" in order to update the Cell Browser.
Example:
private class MyTreeViewModel implements TreeViewModel {
AbstractDataProvider myDataProvider;
public MyTreeViewModel(AbstractDataProvider myDataProvider)
{
this.myDataProvider = myDataProvider;
}
@Override
public NodeInfo> getNodeInfo(T value) {
if(value == null)
{
// Level 0
return new DefaultNodeInfo(myDataProvider, new MyCellImpl());
}
}
}
AbstractDataProvider myDataProvider = new ListDataProvider(new ArrayList()); // or AsyncDataProvider
MyTreeViewModel myModel = new MyTreeViewModel(myDataProvider);
CellBrowser cellBrowser = new CellBrowser.Builder(myModel, null).build();
/*
here you can do some stuff, for example, bind the CellBrowser to a template with UiBinder
*/
/*
if you use a ListDataProvider, do
*/
myDataProvider.setList(myDataStructureFromSomewhere);
myDataProvider.refresh();
/*
if you use an AsyncDataProvider, do
*/
myDataProvider.updateRowData(..., myDataStructureFromSomewhere);
myDataProvider.updateRowCount(...);