【发布时间】:2014-06-14 19:03:53
【问题描述】:
我是使用 Kendo Grid 和 Kendo UI 的新手。我的问题是如何解决这个错误
Uncaught TypeError: Cannot read property 'replace' of undefined
这是我在 KendoGrid 上的代码
$("#Grid").kendoGrid({
scrollable: false,
sortable: true,
pageable: {
refresh: true,
pageSizes: true
},
dataSource: {
transport: {
read: {
url: '/Info/InfoList?search=' + search,
dataType: "json",
type: "POST"
}
},
pageSize: 10
},
rowTemplate: kendo.template($("#rowTemplate").html().replace('k-alt', '')),
altRowTemplate: kendo.template($("#rowTemplate").html())
});
导致错误的行
rowTemplate: kendo.template($("#rowTemplate").html().replace('k-alt', '')),
rowTemplate 的 HTML
<script id="rowTemplate" type="text/x-kendo-tmpl">
<tr class='k-alt'>
<td>
${ FirstName } ${ LastName }
</td>
</tr>
</script>
【问题讨论】:
-
我能看到的唯一原因是jQuery无法找到ID为
rowTemplate的元素...你能记录$("#rowTemplate").length的值并查看返回的内容吗 -
@ArunPJohny 它返回 0
-
这就是原因...您的页面中没有 ID 为
rowTemplate的元素
标签: javascript jquery kendo-ui telerik kendo-grid