Articles in this section
Category / Section

How can I modify the TreeGrid column using an Angular template in ASP.NET MVC?

1 min read

In ASP.NET MVC 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 tree grid column using angular template.

CSHTML

<div ng-app="listCtrl">
<div ng-controller="TreeGridCtrl">
<div style="height:370px;width:100%;" ej-treegrid e-datasource="data" e-editSettings="editSettings" e-columns="columns" e-childmapping="Children">
</div>
</div>    
</div>
<script src="~/Scripts/angular.min.js"></script>
<script src="~/Scripts/ej/ej.widget.angular.min.js"></script>
 
<script type="text/ng-template" id="ngColumnTemplate">
<img src="../../Images/treegrid/{{data.FullName}}.png" /> 
</script>
<script>
var columns = [
{ field: "Address", headerText: "Employee Details", 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",
"Children": [{
"Name": "David william",
"FullName": "David william",
//…
}]
}];
angular.module('listCtrl', ['ejangular'])
.controller('TreeGridCtrl', function ($scope) {
$scope.columns = columns;
//…
});
</script>

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


Conclusion

I hope you enjoyed learning about how to modify the TreeGrid column using an angular template in ASP.NET MVC.

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