0
我希望能够利用数据属性来处理配置我的网格,但无法弄清楚如何为列设置groupHeaderTemplate
。如何使用数据属性为Kendo Grid列设置groupHeaderTemplate?
文档建议我用data-group-header-template
:http://docs.kendoui.com/getting-started/data-attribute-initialization
<table id="grid"
data-role="grid"
data-bind="source: dataSource">
<thead>
<tr>
<th
data-field="ID"
data-group-header-template="t_name">ID</th> <!-- Doesn't work! :(-->
</tr>
</head>
</table>
<script>
kendo.bind($('body'), viewModel);
</script>
如何设置,而不直接调用$.fn.kendoGrid
列上的组头模板?
UPDATE:
我检查了剑道电网的源代码,它似乎并没有设置在列定义的所有属性。
作为参考,在Grid._columns
...
// using HTML5 data attributes as a configuration option
return {
field: field,
type: type,
sortable: sortable !== "false",
filterable: filterable !== "false",
groupable: groupable !== "false",
menu: menu,
template: th.attr(kendo.attr("template")),
width: cols.eq(idx).css("width")
};
后来,在Grid._groupRowHtml
template = column.groupHeaderTemplate; // Wasn't set in _columns. :(
if (template) {
text = typeof template === FUNCTION ? template(data) : kendo.template(template)(data);
}
我指的是模板ID,我没有在例子中包括它。它仍然不起作用,也没有使用字符串模板:http://jsfiddle.net/Ze2bw/3/。我检查了kendo网格源代码,它似乎没有从任何HTML定义的列中映射页眉或页脚模板;它只映射'template'属性。 – jkappers 2013-05-02 22:33:03