ig.TreeHierarchicalDataSource

ig.TreeHierarchicalDataSource_image

The igTreeHierarchicalDataSource component is a client-side component which extends the igDataSource and adds support for hierarchical data with common schema. It features filtering, paging, sorting, updating and load-on-demand support. Support is also available for binding to flat and hierarchical data sources. This component is used by the igTreeGrid control. Further information regarding the classes, events, methods and themes of this API are available under the associated tabs above.

The following code snippet demonstrates how to initialize the TreeHierarchicalDataSource control.

For details on how to reference the required scripts and themes for the TreeHierarchicalDataSource control read, Using JavaScript Resources in Ignite UI and Styling and Theming Ignite UI.

Code Sample

<!doctype html>
<html>
<head>
    <!-- Infragistics Combined CSS -->
    <link href="css/themes/infragistics/infragistics.theme.css" rel="stylesheet" type="text/css" />
    <link href="css/structure/infragistics.css" rel="stylesheet" type="text/css" />
    <style>
        table { width:100%; border-top:1px solid #b1b1b1; border-right:1px solid #b1b1b1; border-spacing: 0;}
        table th, table td { text-align:left; border-bottom:1px solid #b1b1b1; border-left:1px solid #b1b1b1; padding:4px;}
        span[data-level="1"] {
            padding-left: 20px;
        }
        span[data-level="2"] {
            padding-left: 40px;
        }
    </style>
    <!-- jQuery Core -->
    <script src="js/jquery.js" type="text/javascript"></script>
    <!-- jQuery UI -->
    <script src="js/jquery-ui.js" type="text/javascript"></script>
    <!-- Infragistics Combined Scripts -->
    <script src="js/infragistics.core.js" type="text/javascript"></script>
     
    <script type="text/javascript">
        var products  = [
            { "ID": 0, "Name": "Food", "Price": "-", "Category": { "ID": 0, "Name": "Name", "isActive": false }, "Products": [
                {"ID": 15, "Name": "Sandwich", "Price": "-", "Products": [
                    { "ID": 16, "Name": "Club sandwich", "Price": "3.5" }
                ] }
            ]},
            { "ID": 17, "Name": "Accessories", "Price": "-", "Category": { "ID": 1, "Name": "Name1", "isActive": false } },
            {
                "ID": 19, "Name": "Toys", "Price": "-", "Category": { "ID": 2, "Name": "Name2", "isActive": false }, "Products": [
                    { "ID": 20, "Name": "Action Figures", "Price": "3.5" }
                ]
            }
       ];
       $(function () {
            function render(success, error, ds) {
                if (success) {
                    var template = "<tr><td><span data-level='${dataLevel}'>${ID}</span></td><td>${Name}</td><td>${Price}</td></tr>",
                    resultHtml = $.ig.tmpl(template, ds.flatDataView());
                    $("#table").html(resultHtml);
                } else {
                    alert(error);
                }
            }
            var ds = new $.ig.TreeHierarchicalDataSource({
                dataSource: products,
                callback: render,
                treeDS: {
                    childDataKey: "Products",
                    initialExpandDepth: 10,
                    propertyDataLevel: "dataLevel"
                }
            });
                ds.dataBind();
       });
    </script>
</head>
<body>
    <table id="table"></table>
</body>
</html>

Dependencies

jquery.js
infragistics.util.js
infragistics.util.jquery.js

Copyright © 1996 - 2025 Infragistics, Inc. All rights reserved.