Hejsan
I am building GWT Tree and need to get information about level of
current opened TreeItem. Let me describe more detail.
I build up first level(Sport List) of tree so it looks like:
+ Athletics
+ Ice Hockey
+ Footbal
Second level(Countries List) must looks like:
+ Athletics
+ Ice Hockey
+ Canada
+ USA
+ Russia
+ Footbal
Third level(League List) must looks like:
+ Athletics
+ Ice Hockey
+ Canada
+ Tournament
+ 1.League
+ 2.League
+ AAA League
+ USA
+ Russia
+ Footbal
Why I need info abou opened TreeItem? By level of opened TreeItem fire
up different SELECT of database so if I open up "+ Ice Hockey" - it's
first level, then I fire up SELECT on database to get list of
countries for sport "Ice Hockey". Next if I open up country "+ Canada"
then fire up SELECT on databases to get list of all leagues at country
"Canada" for sport "Ice Hockey".
I call open handler for Tree for TreeItem like this:
// Add a handler that automatically generates some children
statTree.addOpenHandler(new OpenHandler<TreeItem>() {
public void onOpen(OpenEvent<TreeItem> event) {
// tree item that was clicked
TreeItem itemSelected = event.getTarget();
if (itemSelected.getChildCount() == 1) {
// Close item immediately
itemSelected.setState(false, false);
// Add a random number of children to
the item
String itemText =
itemSelected.getText();
// different request to database,
according level of TreeItem
// ??
// just temporary dummy data
of subtree items
int numChildren = Random.nextInt(5) + 2;
for (int i = 0; i < numChildren; i++) {
// tree item to be added
TreeItem childDescendant =
itemSelected
.addItem(itemText + "." + i);
System.out.println("\ncildDescendant index: "
+
itemSelected.getChildIndex(childDescendant));
childDescendant.addItem("");
}
// Remove the temporary item when we
finish loading
itemSelected.getChild(0).remove();
// Reopen the item
itemSelected.setState(true, false);
}
}
});
Please help me with this problem, I'd appreciate it.
junior
--
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.