最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Kendo UI Grid, Uncaught Error: Invalid Template - Stack Overflow

programmeradmin1浏览0评论

Trying to put an array i've formatted into 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
    });
});

Trying to put an array i've formatted into 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.

Share Improve this question asked Aug 14, 2015 at 16:01 ArthurArthur 2792 silver badges12 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

The reason for the "Invalid template" error is that it looks like you're trying to set the columns' fields by index, e.g.:

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.

发布评论

评论列表(0)

  1. 暂无评论