columns.template String|Function

The template which renders the column content. The treelist renders table rows (<tr>) which represent the data source items. Each table row consists of table cells (<td>) which represent the treelist columns. By default the HTML-encoded value of the field is displayed in the column.

Use the template to customize the way the column displays its value.

Example - set the template as a string (wrap the column value in HTML)

<div id="treelist"></div>
<script>
  $("#treelist").kendoTreeList({
    columns: [
      { field: "lastName" },
      { field: "position", template: "<strong>#: position #</strong>" }
    ],
    dataSource: {
      data: [
        { id: 1, parentId: null, lastName: "Jackson", position: "CEO" },
        { id: 2, parentId: 1, lastName: "Weber", position: "VP, Engineering" }
      ]
    }
  });
</script>

Example - external template with conditional formatting and button handler

<div id="treelist"></div>

<script type="text/x-kendo-template" id="template">
    # if (data.allowVote) { #
        <button class='k-button btn-vote'>Vote</button>
    # } #
</script>

<script>
$("#treelist")
  .kendoTreeList({
    columns: [
      { field: "name" },
      { template: $("#template").html() }
    ],
    dataSource: [
      { allowVote: true, name: "Jane Doe" },
      { allowVote: true, name: "Joseph Doe" },
      { name: "John Doe" }
    ]
  })
  .on("click", ".btn-vote", function(e) {
    var treelist = $(e.delegateTarget).data("kendoTreeList");
    var dataItem = treelist.dataItem(e.currentTarget);
    alert("Voted for " + dataItem.name)
  });
</script>
In this article
Not finding the help you need?