【问题标题】:How to change column title dynamically in Kendo UI TreeList?如何在 Kendo UI TreeList 中动态更改列标题?
【发布时间】:2016-05-16 11:56:58
【问题描述】:

我需要根据数据更改列标题/标题。有没有办法实现这个功能。

目前标题硬编码如下:

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

【问题讨论】:

  • 你可以分配一个具有所需标题字符串的变量,你也可以给我一个例子,说明在什么样的数据上设置什么标题
  • 谢谢你的回复!!!它奏效了

标签: jquery .net asp.net-mvc kendo-ui kendo-treelist


【解决方案1】:

Demo

1- 使用headerTemplate

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

2-或通过jQuery改变列标题

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

【讨论】:

  • 这不会更改导出的 excel 文件中的标题。 (2号)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-05-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多