2016-05-16 99 views
1

我需要根據數據更改列標題/標題。有什麼辦法可以實現這個功能。如何在Kendo UI TreeList中動態更改列標題?

目前的標題是硬編碼如下:

 $("#grid").kendoTreeList({ 
      dataSource: drillDownDataSource, 
      resizable: true, 
      autoBind: true, 
      columns: [ 
       { field: "Title", title: " ", width: "297px" }, 
       { field: "EndingBalance", title: "EndingBalance", template: "#: FormatNumberToEn(EndingBalance) #" }, 
       { field: "EndingBalance1", title: "EndingBalance1", template: "#: FormatNumberToEn(EndingBalance1) #" }, 
       { field: "EndingBalance2", title: "EndingBalance2", template: "#: FormatNumberToEn(EndingBalance2) #" }, 
       { field: "EndingBalance3", title: "EndingBalance3", template: "#: FormatNumberToEn(EndingBalance3) #" }, 
       { field: "EndingBalance4", title: "EndingBalance4", template: "#: FormatNumberToEn(EndingBalance4) #" } 
      ], 
      dataBound: function (e) { 
       $('#grid').show(); 
       $('#GridPanelLoading').hide(); 
      }, 
+0

你可以分配一個變量,它具有所需的標題字符串,你也可以給我一個什麼樣的數據設置什麼樣的標題的例子 –

+0

謝謝你的答覆人!有效 –

回答

3

看到Demo

1-使用headerTemplate

$("#treelist").kendoTreeList({ 
     columns: [ { 
      field: "name", 
      headerTemplate: '#= getHeader() #' 
     }], 
... 

2-或改變列標題的jQuery

$("#treelist thead [data-field=name]").html("New Title")