How can I configure SmartGWT TreeGrid to use different types of objects?

陌路散爱 提交于 2019-12-12 06:32:36

问题


I have this usecase:

  1. I get all of my Customers.
  2. For each Cutomer, I want to get his Receipt.
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!