views:

24

answers:

0

I want to use SmartGWT's TreeGrid object to show hierarchical data. The data is heterogeneous, not all elements are of the same type and have the same fields. For example, I have the following data:

Home
 |-Room 1
 |-Room 2
    |-Table
    |-Chair

All objects have unique IDs. Home has no fields. Rooms have just a name. Table has a name and an int field "seatsNumberOfPeople" which the Chair has not. Chair has a field "Color" taken from a list of possible values which the table has not.

When an object in the TreeGrid is selected, I want to show a DetailViewer which lets the user edit the fields of that object. Obviously, the DetailViewer will have different fields and validations for each type of node.

How should the DataSource be designed to meet these requirements? What's the best practice to create such dynamic DetailViewer from that heterogeneous data?

Unfortunately, all examples on the web show data which is homogeneous (same fields for all objects in the Tree).