I use a custom TreeViewModel instead of handling selection events. When a user clicks on a level 1 node, TreeViewModel.getNodeInfo(...) method is called
The method creates a data provider that corresponds to the type of value parameter. The data provider initiates an RPC call in its constructor. When the data provider receives results back from the server it populates itself with the data received by calling updateRowCount() and updateRowData() This works well when the number of children under parent node is small. If it is large AbstractDataProvider<T>.onRangeChanged() can be used to query only currently visible children. Is this something you are looking for? On Dec 25, 9:27 pm, Sydney <[email protected]> wrote: > I have a 3 level CellBrowser. Everything is working fine using a > ListDataProvider except that it's too long to grab the data from the server. > So I want to use the AsyncDataProvider to fetch only the data that the user > actually needs. Basically what I want to do is when the user selects the > level1 value, the level2 provider executes a RPC call to get the level2 data > based on the selected level1 parent. The problem is that the onRangeChanged > method is called before the onSelectionChange, so when the RPC call is done > the level1 value is still null. What is the proper way to use > AsyncDataProvider to grab the level2 data depending on the level1 selected > value? > > public class SportTreeModel implements TreeViewModel, Handler { > private AsyncDataProvider<Level1Node> level1Provider; > private AsyncDataProvider<Level2Node> level2Provider; > private final SingleSelectionModel<Level1Node> level1SelectionModel; > // In the construtor I create these objets > // In getNodeInfo I link a cell with the data provider and the selection > model > > @Override > public void onSelectionChange(SelectionChangeEvent event) { > Object src = event.getSource(); > if (src == level1SelectionModel) { > Level1Node level1 = level1SelectionModel.getSelectedObject(); > ((MyAsyncLevel2Provider) > level2Provider).setLevel1(level1.getValue()); > } > } > > } > > Thanks -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
