【发布时间】:2014-06-09 03:47:14
【问题描述】:
我是使用 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>
谢谢:)
【问题讨论】:
-
因为
$("#rowTemplate").html()返回未定义 -
你的页面中是否有id为
rowTemplate的元素 -
@ArunPJohny 是的。等我更新我的问题
-
你能在
$("#Grid").kendoGrid({..});之前做alert($("#rowTemplate").length)吗 -
@ArunPJohny 先生,它会提醒
0接下来我该怎么做?还检查了 id 的命名,但它们都是唯一的
标签: c# jquery asp.net-mvc gridview kendo-ui