How to expand/collapse .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.
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 forums, Direct-Trac, or feedback portal. We are always happy to assist you!