剑道网格标题更改 [英] kendo grid title change

查看:79
本文介绍了剑道网格标题更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改剑道网格的标题.

I am trying to change the title of the kendo grid.

但是,当我在change事件上执行以下操作时,该列将无法使用过滤功能. 我在这里有一个示例代码来复制jsfiddle中的问题: http://jsfiddle.net/nLn5b/4/

However when i do the below on change event the filtering doesn't work for that column. I have a sample code here to replicate the issue in jsfiddle: http://jsfiddle.net/nLn5b/4/

$("#change").on("click", function() {
$("#grid th[data-field=FirstName]").html("<a tabindex='-1' class='k-grid-filter'     href='#'><span class='k-icon k-filter'></span></a>MiddleName")
})

var grid = $("#grid").kendoGrid({
dataSource: {
    data    : createRandomData(10),
    pageSize: 5,
    schema  : {
        model: {
            fields: {
                Id       : { type: 'number' },
                FirstName: { type: 'string' },
                LastName : { type: 'string' },
                City     : { type: 'string' }
            }
        }
    }
},
editable  : false,
pageable  : true,
filterable: true,
columns   : [
    { field: "FirstName", width: 90, title: "First Name" },
    { field: "LastName", width: 90, title: "Last Name" },
    { field: "City", width: 100 }
]
}).data("kendoGrid");

感谢您的帮助.

推荐答案

为什么要在运行时而不是在创建时更改title?无论如何,您可以使用:

Why do you want to change the title in runtime instead of while creating it? Anyhow, you can do it using:

$("#change").on("click", function() {
    $("#grid th[data-field=FirstName]").contents().last().replaceWith("MiddleName");
});

您的JSFiddle在此处进行了修改: http://jsfiddle.net/OnaBai/nLn5b/5/

Your JSFiddle modified here: http://jsfiddle.net/OnaBai/nLn5b/5/

这篇关于剑道网格标题更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆