Uncaught TypeError:无法读取未定义的属性'替换' [英] Uncaught TypeError: Cannot read property 'replace' of undefined

查看:426
本文介绍了Uncaught TypeError:无法读取未定义的属性'替换'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用Kendo Grid和Kendo UI的新手。我的问题是我怎么解决这个错误

 未捕获TypeError:无法读取未定义
的属性'replace' code>

这是我在KendoGrid上的代码

  $(#Grid)。kendoGrid({
scrollable:false,
sortable:true,
可分页:{
refresh:true,
pageSizes:true
},
dataSource:{
transport:{
read:{
url:'/ Info / InfoList?search ='+ search,
dataType:json,
类型:POST
}
$ b $,
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 = rowTemplatetype =text / x-kendo-tmpl> 
< tr class ='k-alt'>
< td>
$ {FirstName} $ {LastName}
< / td>
< / tr>
< / script>

谢谢:)

解决方案



首先找到元素

  var rowTemplate = document.getElementsByName(rowTemplate); 

  var rowTemplate = document.getElementById(rowTemplate); 

  var rowTemplate = $('#rowTemplate'); 

然后再次尝试您的代码

rowTemplate .html()。replace(....)



这个问题已经在:
Uncaught TypeError:无法读取网格中未定义属性'replace'


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 

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())
        });

Line that Causes the Error

rowTemplate: kendo.template($("#rowTemplate").html().replace('k-alt', '')),

HTML of rowTemplate

   <script id="rowTemplate" type="text/x-kendo-tmpl">   
        <tr class='k-alt'>
            <td>
                ${ FirstName } ${ LastName }
            </td>
        </tr>
            </script>

Thanks :)

解决方案

I think jQuery cannot find the element.

First of all find the element

var rowTemplate= document.getElementsByName("rowTemplate");

or

var rowTemplate = document.getElementById("rowTemplate"); 

or

var rowTemplate = $('#rowTemplate');

Then try your code again

rowTemplate.html().replace(....)

This question is already available in: Uncaught TypeError : cannot read property 'replace' of undefined In Grid

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

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