简体   繁体   English

如何在Kendo UI TreeList中动态更改列标题?

[英]How to change column title dynamically in Kendo UI TreeList?

I need to change the column header/title according to the data. 我需要根据数据更改列标题/标题。 is there any way to achieve this functionality. 有没有办法实现这个功能。

Currently the title is hard coded as follows: 目前标题的硬编码如下:

        $("#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();
            },

see Demo 演示

1- use headerTemplate 1-使用headerTemplate

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

2- or change column header by jQuery 2-或通过jQuery更改列标题

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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