简体   繁体   中英

kendo ui treelist - set cell template

I would like to set a span in every cell of Kendo TreeList , I am getting this by default in Kendo Grid but I am not able to set this in Kendo TreeList

Kendo Grid :

    <td role="gridcell" title="Control Box">
          <span ng-bind="dataItem.partdesc" class="ng-binding">Control Box</span>    
    </td>

Kendo TreeList :

    <td role="gridcell" title="Control Box"></td>

I would suggest you two workaround, first you can use column template (but you have to modify all column if you want every cell to have span like the one you described) like eg

$("#treelist").kendoTreeList({
  columns: [ {
    field: "name",
    template: "<span class='Test'>#:name#</span> "
  }],
  dataSource: [ { name: "Jane Doe" }, { name: "John Doe" } ]
});

DEMO

Or you can insert the span on databound like eg

$("#treeList").kendoTreeList({
      columns: [
        { field: "Name" },
        { field: "Position" }
      ],
      dataSource: [
        { id: 1, Name: "Daryl Sweeney", Position: "CEO", parentId: null },
        { id: 2, Name: "Guy Wooten", Position: "Chief Technical Officer", parentId: 1 }
      ],
      dataBound: function(e) {
        e.sender.table.find("td[role='gridcell']").append("<span class='test'>Test</span>");
      }
 });

DEMO

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM