未捕获的TypeError:无法读取未定义的属性'replace'在Grid中 [英] Uncaught TypeError : cannot read property 'replace' of undefined In Grid

查看:518
本文介绍了未捕获的TypeError:无法读取未定义的属性'replace'在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(....)

这篇关于未捕获的TypeError:无法读取未定义的属性'replace'在Grid中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆