kendo grid title change

别说谁变了你拦得住时间么 提交于 2019-12-13 02:59:39

问题


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

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");

Thanks for any help.


回答1:


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");
});

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




回答2:


I believe it is more clear this way:

$("#grid th[data-field=FirstName]").html("MiddleName");


来源:https://stackoverflow.com/questions/24611267/kendo-grid-title-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!