简体   繁体   English

Kendo UI网格,未捕获的错误:无效的模板

[英]Kendo UI Grid, Uncaught Error: Invalid Template

Trying to put an array i've formatted into kendo UI Grid. 试图将我格式化的数组放入kendo UI Grid中。 This is the code I'm using. 这是我正在使用的代码。

 $(document).ready(function (){ $("#grid").kendoGrid({ columns: [ { title: "Ticket Number", field: "0" }, { title: "Title", field: "1" }, { title: "Created On", field: "2" }, { title: "Modified On", field: "3" }, { title: "Queue", field: "4" }, { title: "Status", field: "5" }, { title: "Account", field: "6" }, { title: "Contact", field: "7" }, { title: "Service Type", field: "8" }, { title: "Issue Type", field: "9" } ], dataSource: dataset }); }); 

the variable dataset contains a list of columns and rows with the data I wish to display. 变量数据集包含列和行的列表,以及要显示的数据。 When Running the code I get: 运行代码时,我得到:

 Uncaught Error: Invalid template:'<tr data-uid="#=data.uid#" role='row'> 

I'm not sure what I'm doing wrong. 我不确定自己在做什么错。 The data in the array is in the correct order, and the columns are rendering on the page. 数组中的数据顺序正确,列在页面上呈现。 but it dosen't seem to want to insert my data. 但它似乎不想插入我的数据。

The reason for the "Invalid template" error is that it looks like you're trying to set the columns' fields by index, eg: 出现“无效模板”错误的原因是,您似乎试图按索引设置列的字段,例如:

field: "0"

You're actually parsing strings here, though. 不过,您实际上是在这里解析字符串。 Rather, you should provide the actual field names from your dataset: 相反,您应该从数据集中提供实际的字段名称:

<script>
  $(function (){
      var dataset = [
        { ticketId: "1000", title: "Lorem" },
        { ticketId: "1001", title: "Ipsum" }
      ];

      $("#grid").kendoGrid({
        columns: [
          { title: "Ticket Number", field: "ticketId" },
          { title: "Title", field: "title" }
        ],
        dataSource: dataset
      });
  });
</script>

Here's a working sample . 这是一个工作样本

That will probably work, but without an exacte sample of your dataset there is nothing further to assist with. 这可能会起作用,但是如果没有确切的数据集样本,则没有其他进一步的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM