locked
How to display treeview feature in webgrid? RRS feed

  • Question

  • User-1651604128 posted

    I am using asp.net mvc webgrid to display tablet data from SQL table,

    in one webgrid, I need to data in something like treeview feature, basically, the data is categorized by different categories, and each category has a plus (+) sign with a icon in from of it, click it to get the next level and finally get the detailed data line, user select that details data level to show the details in a form.

    Is there any way to make it working in that way?

    thanks a lot,  

    Thursday, September 26, 2019 6:49 PM

All replies

  • User-474980206 posted

    Google nested mvc grid. Here is a sample

    https://www.aspsnippets.com/Articles/Implement-Nested-WebGrid-with-Expand-Collapse-in-ASPNet-MVC.aspx

    I probably would use a JavaScript grid that supports this (most do).

    Friday, September 27, 2019 2:22 PM
  • User-1651604128 posted

    bruce (sqlwork.com)

    Google nested mvc grid. Here is a sample

    https://www.aspsnippets.com/Articles/Implement-Nested-WebGrid-with-Expand-Collapse-in-ASPNet-MVC.aspx

    I probably would use a JavaScript grid that supports this (most do).

    Hi Bruce, Thanks a lot for your help,

    I study the method, in order to make it working, it needs the Customer and Order tables, and they are one to many relationships in the database,

    But in my case, I don't have these two tables existed in database, I need to simulate it. Basically, my codes need to read one table of data and based on this data to read another table in another server and then build a new dataset, the new dataset will be categorized, the new categories is similar as the Customer table (will be on the Plus sign level), and rest of data will be second level as the details level, so clicking the Categorized level (Plus sign) will show the details level), The new generated dataset is not sitting in the database, it is just a list as a temporary location to hold data, I have challenge in this part to simulate the MVC model as in example you provided.

    Any idea?  Can I use datatable to achieve my goal? or if there is any other better solution? thanks a lot again

      

    Monday, September 30, 2019 2:06 PM
  • User-474980206 posted

    a tree view a nest of collection in collections to as deep as you want. this has nothing to do with data tables. the outer grind bind to the outer collection, for which each item has another collection that you bind the sub grid to, and so on. if only two deep, linq's group by works perfect.

    Monday, September 30, 2019 7:32 PM
  • User-1651604128 posted

    a tree view a nest of collection in collections to as deep as you want. this has nothing to do with data tables. the outer grind bind to the outer collection, for which each item has another collection that you bind the sub grid to, and so on. if only two deep, linq's group by works perfect.

    Sorry for the confusing, I wanted to say that the challenge for me is that the data is in the temporary location, either list or datatable, Not in the SQL table of SQL database,

    so basically, when user click to launch the treeview, a list or datatable is created from other SQL tables based on a logic, then I need to use this list or datatable to build a treeview and displayed (be used) by users, the treeview is built dynamically on the fly, Not directly from a static SQL table in SQL database,

    Hopefully, you understand my request this time. thanks a lot again.  

    Tuesday, October 1, 2019 12:19 PM
  • User475983607 posted

    Can you explain why the data source makes a difference?  Share you code so the community can have a basic understanding of the design intent.

    Tuesday, October 1, 2019 12:22 PM
  • User-17257777 posted

    Hi Peter,

    Whether the data is from a database or from temporary location, it doesn't make a difference. In the example provided by Bruce, you only need to replace the data source with the temporary location data. If you have any problems, please show us the codes and the final result you want to get.

    Best Regards,

    Jiadong Meng

    Monday, October 21, 2019 2:07 AM