Articles in this section

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

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 TreeGrid in ASP.NET MVC.
Grid records at particular level
.You can refer to our ASP.NET MVC Tree Grid feature tour page to know about its other groundbreaking feature representations documentation and how to quickly get started for configuration specifications.  You can also explore our ASP.NET MVC Tree Grid 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)
Access denied
Access denied