未捕获的类型错误:无法读取网格中未定义的属性“替换" [英] Uncaught TypeError : cannot read property 'replace' of undefined In Grid
本文介绍了未捕获的类型错误:无法读取网格中未定义的属性“替换"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是使用 Kendo Grid 和 Kendo UI 的新手.我的问题是如何解决这个错误
I'm new in using Kendo Grid and Kendo UI . My question is how can i resolve this Error
Uncaught TypeError: Cannot read property 'replace' of undefined
这是我在 KendoGrid 上的代码
This is my Code on my 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
HTML of rowTemplate
<script id="rowTemplate" type="text/x-kendo-tmpl">
<tr class='k-alt'>
<td>
${ FirstName } ${ LastName }
</td>
</tr>
</script>
推荐答案
我认为 jQuery 找不到该元素.
I think jQuery cannot find the element.
首先找到元素
var rowTemplate= document.getElementsByName("rowTemplate");
或
var rowTemplate = document.getElementById("rowTemplate");
或
var rowTemplate = $('#rowTemplate');
然后再次尝试您的代码
rowTemplate.html().replace(....)
这篇关于未捕获的类型错误:无法读取网格中未定义的属性“替换"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文