We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to customize the TreeGrid column using angular template ?

Platform: jQuery |
Control: ejTreeGrid |
Published Date: August 16, 2018 |
Last Revised Date: May 29, 2019

In 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.

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile