动态编辑Kendo网格列的模板

时间:2016-11-21 07:42:41

标签: kendo-grid

我有一个Kendo网格,最初呈现为

$("#dataGrid").kendoGrid({ 
                    height: 450,
                    sortable: true,
                    columns:[     
                            {field: "Status", title: " ", width:35},
                            {field: "Year", title:" ", width:50},
                            {field: "Name", title:" ", width:50}
                            ],
                    dataSource: surveydataSource
                });

我的要求是在某些函数调用中,我想更改" Name"的模板。剑道网格中的列为:

$("#dataGrid").kendoGrid({ 
                    height: 450,
                    sortable: true,
                    columns:[     
                            {field: "Status", title: " ", width:35},
                            {field: "Year", title:" ", width:50},
                            {field: "Name", title:" ", width:50, template: "<strong>#: name # </strong>"}
                            ],
                    dataSource: surveydataSource
                });

有没有更简单的方法,而不是再次构建整个网格?我可以在kendo网格中更改/重置列的模板吗?

1 个答案:

答案 0 :(得分:0)

尝试使用Kendo Grid .setOptions()方法进行设置。

var grid = $("#dataGrid").data("kendoGrid");
    grid.setOptions({
        columns: [     
            {field: "Status", title: " ", width:35},
            {field: "Year", title:" ", width:50},
            {field: "Name", title:" ", width:50, template: "<strong>#: name # </strong>"}
        ]
    });