admin管理员组文章数量:1333420
I try to use a kendo grid with knockout binding and Knockout-Kendo.js library
It is defined as below:
<div data-bind="kendoGrid:
{
data: SearchResult,
rowTemplate: 'rowTmpl',
altRowTemplate: 'altTmpl',
useKOTemplates: true
}">
</div>
<script id="rowTmpl" type="text/html">
<tr class="tdText" role="row">
<td >
<a data-bind="attr: { href: 'scrccc_checkEdit.aspx?id=' + CheckID }" >
<img src="images/icon-edit.gif" border="0" alt="Edit/View Check" />
</a>
</td>
<td data-bind="text: CheckNumber"></td>
<td data-bind="text: new Date(CreateDate).MMddyyyy()"></td>
//...
<td data-bind="text: ParishName">
</tr>
</script>
<script id="altTmpl" type="text/html">
//....
The data loaded from the REST service has more columns that I want to be shown in grid The row looks ok, due to template, but the problem is with the grid header, create columns for every field in source.
How can I hide some columns in header, and customize their header label (change column width, header label and eventually allow additional customization .
For example, in image above I want Co
I try to use a kendo grid with knockout binding and Knockout-Kendo.js library
It is defined as below:
<div data-bind="kendoGrid:
{
data: SearchResult,
rowTemplate: 'rowTmpl',
altRowTemplate: 'altTmpl',
useKOTemplates: true
}">
</div>
<script id="rowTmpl" type="text/html">
<tr class="tdText" role="row">
<td >
<a data-bind="attr: { href: 'scrccc_checkEdit.aspx?id=' + CheckID }" >
<img src="images/icon-edit.gif" border="0" alt="Edit/View Check" />
</a>
</td>
<td data-bind="text: CheckNumber"></td>
<td data-bind="text: new Date(CreateDate).MMddyyyy()"></td>
//...
<td data-bind="text: ParishName">
</tr>
</script>
<script id="altTmpl" type="text/html">
//....
The data loaded from the REST service has more columns that I want to be shown in grid The row looks ok, due to template, but the problem is with the grid header, create columns for every field in source.
How can I hide some columns in header, and customize their header label (change column width, header label and eventually allow additional customization .
For example, in image above I want Co
Share Improve this question edited Feb 8, 2017 at 14:48 CommunityBot 11 silver badge asked Dec 2, 2013 at 17:39 bzamfirbzamfir 4,90611 gold badges57 silver badges91 bronze badges3 Answers
Reset to default 5There is currently a specific option to specify the header template directly. What you could do is specify a set of columns and their headers directly either by using the title
or headerTemplate
options like:
this.gridOptions = {
data: this.items,
rowTemplate: "rowTmpl",
useKOTemplates: true,
columns: [
{
title: "My ID"
},
{
headerTemplate: "<strong>Name Edit</strong>"
},
{
title: "Name Value"
}
]
};
Sample: http://jsfiddle/rniemeyer/yjYMK/
You can make the customizations you need by providing the grid with individual column definitions. With those, you can set the width, provide a headerTemplate, hide columns:
columns: [{
field: "FieldName",
title: "Contact Name",
headerTemplate: "This will be shown in the header",
template: "This will be shown in the column",
hidden: true,
width: 140
}]
Also worth noting that you can apply bindings to your templates. The following example uses a knockout binding:
columns: [{
field: 'FieldName',
headerTemplate: '<span data-bind="text:headerName"></span>',
template: 'This will be shown in the column'
}]
本文标签: javascriptCustomize headers for a kendo grid using KnockoutKendojs for ko bindingStack Overflow
版权声明:本文标题:javascript - Customize headers for a kendo grid using Knockout-Kendo.js for ko binding - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742326171a2453770.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论