未捕获的TypeError:无法读取未定义的属性'replace'在Grid中

Ren*_*Tao 15 javascript jquery telerik kendo-ui kendo-grid

我是使用Kendo Grid和Kendo UI的新手.我的问题是如何解决此错误

Uncaught TypeError: Cannot read property 'replace' of undefined 
Run Code Online (Sandbox Code Playgroud)

这是我在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())
        });
Run Code Online (Sandbox Code Playgroud)

导致错误的行

rowTemplate: kendo.template($("#rowTemplate").html().replace('k-alt', '')),
Run Code Online (Sandbox Code Playgroud)

rowTemplate的HTML

 <script id="rowTemplate" type="text/x-kendo-tmpl">   
        <tr class='k-alt'>
            <td>
                ${ FirstName } ${ LastName }
            </td>
        </tr>
            </script>
Run Code Online (Sandbox Code Playgroud)

Dr.*_*asu 23

我认为jQuery无法找到该元素.

首先找到元素

var rowTemplate= document.getElementsByName("rowTemplate");
Run Code Online (Sandbox Code Playgroud)

要么

var rowTemplate = document.getElementById("rowTemplate"); 
Run Code Online (Sandbox Code Playgroud)

要么

var rowTemplate = $('#rowTemplate');
Run Code Online (Sandbox Code Playgroud)

然后再次尝试您的代码

rowTemplate.html().replace(....)
Run Code Online (Sandbox Code Playgroud)