问题
I have this usecase:
- I get all of my Customers.
- For each Cutomer, I want to get his Receipt.
- For each Receipt, I want to get all ShoppingItems.
From the examples I can see how TreeGrid works if I had a hierarchy of objects of the same type, but I don't know how this would work with my usecase. Of course, if there's a better component to show this kind of data/connections, that would be good too :)
回答1:
You can use the Tree
(the model behind the TreeGrid
) in Parent mode.
When you build you Tree
from the data you receive from the server
You can add attribute to each node saying this node is of Customer type, this one has Customer1 as a parent and is of Receipt type. Another will be node with Receipt1 as parent and with ShoppingItems type.
When you build you Tree from the data you receive from the server
you can in the same time you are setting the type attribute set the icon of the node to reflect the type of your element.
Up to you to set such node as folder or not (for example Customers, Receipt will be folders but ShoppingItems not and will be just a leaf).
Hope It could help
来源:https://stackoverflow.com/questions/12365887/how-can-i-configure-smartgwt-treegrid-to-use-different-types-of-objects