Both ListGrid and Treenode are extensions of com.smartgwt.client.core.DataClass.
Therefore, you should be able to use get/setAttributexxx to retrieve/store values of disparate types.
For hierarchical structure, you should be able to use TreeNode. TreeNode is used either in
parent-linked mode: SmartSample/#tree_databinding_parentlinking,
or child-linked mode: SmartSample/#tree_databinding_children_arrays
Study Showcase.java, which together with SideNavTree.java, ExplorerTreeNode.java and ShowcaseData.java to form the backbone of the Showcase samples.
In the ExplorerTreeNode.java, an object is retrieved/stored using get/setAttributeAsObject, where the object is a PanelFactory. PanelFactory interface is somewhat devised to produce the corresponding sample on the rhs of the page.
Instead of PanelFactory, you could have your own class called ItemContainer, for example. You could store the object as an attribute directly, and then you would have to test the type of the object to decide what to do with it.
However, how to store objects of disparate types has less to do with SmartGWT than being familiar with the restrictions of GWT. GWT does not allow an object to be stored as a general Object class, for optimisation reasons. You need to draw on your personal expertise and strategies on GWT on how to treat general objects without being stored as Object class.
Since the general type of object must have specific type that conforms to GWT’s requirement for source-code availability and Serializable, you could design that object to implement an interface of ItemContainer or ItemFactory, with an action method
interface ItemContainer<Whatever>{
Whatever whatToDo();
}
Observe PanelFactory interface.
public interface PanelFactory {
Canvas create();
String getID();
String getDescription();
}
Note that Canvas is a specific base type to which you could assign general extended types of Canvas. Similarly, you need to design your general objects with a strategy that satisfies GWT’s restriction.