Articles in this section
Category / Section

How to expand/collapse .NET MVC TreeGrid records at particular level?

1 min read

In ASP.NET MVC TreeGrid, we can expand or collapse particular level parent tasks using “expandAtLevel” and “collapseAtLevel” public methods. The following code example explains how to expand or collapse particular level parent items in TreeGrid.

 
<body>   
    <button id="expand">Expand at level 1</button>
    <button id="collapse">Collape at level 1</button> 
    @(Html.EJ().TreeGrid("TreeGridContainer").
           //…
    )
    <script type="text/javascript">      
       $("#expand").click(function () {
           var obj = $("#TreeGridContainer").data("ejTreeGrid");
           obj.expandAtLevel(1);
       })
       $("#collapse").click(function () {
           var obj = $("#TreeGridContainer").data("ejTreeGrid");
           obj.collapseAtLevel(1);
       })
   </script> 
</body>

Here we have collapsed the 1st level parent records and expanded the 1st level parent on the button click action.

Sample

A simple sample to expand and collapse at particular level in TreeGrid.

Sample


 


Conclusion

I hope you enjoyed learning about how to expand/collapse .NET MVC TreeGrid records at particular level.

You can refer to our ASP.NET MVC TreeGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our ASP.NET MVC
TreeGrid
 example 
to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied