我有以下代码:
$("#grid").kendoGrid({
dataSource: {
type: "odata",
data: scannedResult.targetList,
pageSize: 20
},
height: 550,
groupable: true,
sortable: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
columns: [{
field: "proccess",
title: "Contact Name",
width: 200
}, {
field: "status",
title: "status"
}, {
field: "comment",
title: "comment"
}]
});
创建一个剑道简单网格。更详细的是我的矮人。
现在,该字段status
可以是3个值中的1个:通过,失败,跳过。我希望该status
列将显示一个图标而不是值。虽然代码很简单,但我不知道如何使该列成为自定义列。
有没有一种方法可以使列成为自定义列?
您应该使用模板定义。就像是:
<script id="status-template" type="text/kendo-templ">
# if (data.status === 1) { #
<span>Status1</span>
# } else if (data.status === 2) { #
<span>Status 2</span>
# } else { #
<span>Status 3</span>
# } #
</script>
columns: [{
field: "proccess",
title: "Contact Name",
width: 200
}, {
field: "status",
title: "status",
template: $("#status-template").html()
}, {
field: "comment",
title: "comment"
}]
看到它在这里运行:http : //jsfiddle.net/OnaBai/5x8wt0f7/
显然,模板可以发出任何HTML代码,它可能是链接,图像...
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句