Articles in this section
Category / Section

How to customize the JavaScript TreeGrid column using angular template in JavaScript?

1 min read

In JavaScript TreeGrid, the column can be customized with angular template by defining the isTemplateColumn and angularTemplate properties in column array collection.

  • isTemplateColumn is a Boolean property used to denote a template column.
  • angularTemplate is a property used to map the template ID to the column.

The below code snippet explains how to customize the TreeGrid column using angular template.

<html lang="en" ng-app="listCtrl">
//…
<body ng-controller="TreeGridCtrl">
    <div ej-treegrid id="treegrid" e-datasource="data" e-editsettings="editSettings" e-columns="columns" e-childmapping="Children" e-isresponsive="true" e-rowheight="rowHeight">
    </div>
    //…
    <script type="text/ng-template" id="ngColumnTemplate">
        <div style="padding:5px;">
            <div style="position:relative;top:-10px;display:inline-block;">
                <img src="16.2.0.41/themes/web/content/images/treegrid/{{data.FullName}}.png" />
            </div>
            <div style="display:inline-block;">
                <div style="padding:5px;">{{data.Address}}</div>
                <div style="padding:5px;">{{data.Contact}}</div>
            </div>
        </div>
     </script>
    <script>
        var columns = [{
            field: "Address",
            headerText: "Employee Details",
            width: "200px",
            isTemplateColumn: true,
            angularTemplate: "#ngColumnTemplate"
        },
            //…
        ];
        var treeData = [{
            "Name": "Robert King",
            "FullName": "Robert King",
            "Designation": "Chief Executive Officer",
            "EmployeeID": "EMP001",
            "Address": "507 - 20th Ave. E.Apt. 2A, Seattle",
            "Contact": "(206) 555-9857",
            "Country": "USA",
            "DOB": "2/15/1963",
            //…
        }];
        angular.module('listCtrl', ['ejangular'])
            .controller('TreeGridCtrl', function ($scope) {
                $scope.columns = columns;
                //…
            });
    </script>
</body>
</html>

The above column template will be displayed in TreeGrid as like below screenshot.

Customize the treegrid column with angular template.

Sample for rendering a TreeGrid column with angular template is available here.

 

Conclusion

I hope you enjoyed learning about how to customize the JavaScript TreeGrid column using angular template in JavaScript.

You can refer to our JavaScript 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 JavaScript 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