How to expand/collapse records at specific levels?
It is possible to expand/collapse parent nodes at specific levels using expandAtLevel and collapseAtLevel public methods. The following code snippet explains how to expand or collapse nodes at specific nodes in jQuery TreeGrid.
<html> <body> <button id="expand">Expand At level 2</button> <button id="collapse">Collapse At Level 1</button> <script type="text/javascript"> $("#TreeGridContainer").ejTreeGrid({ //... }) var treeobj = $("#TreeGridContainer").data("ejTreeGrid"); $("#expand").click(function () { treeobj.expandAtLevel(2); }) $("#collapse").click(function () { treeobj.collapseAtLevel(1); }) </script> </body> </html>
Sample:
Click here to view the sample to expand/collapse nodes at specific levels in TreeGrid.
Conclusion
Hope you enjoyed learning about how to expand/collapse records at specific levels.
You can refer to our jQuery TreeGrid’s feature tour page to learn about its other groundbreaking feature representations. You can explore our jQuery TreeGrid documentation to understand how to present and manipulate data.
For current customers, you can check out our jQuery 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 jQuery TreeGrid and other jQuery components.
If you have any queries or require clarifications, please let us know in the comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!