sql - KendoGrid JavaScript runtime error: Invalid template - Stack Overflow

Trying to figure out the Kendo world and having an issue with a grid set to a json array datasource.Err

Trying to figure out the Kendo world and having an issue with a grid set to a json array datasource.

Error is "JavaScript runtime error: Invalid template: <tr
data-uid="#=data.uid#" role='row'><td  role='gridcell'>#=data.Account
Num==null?'':data.Account Num#</td>...".

I notice that in this error I see nulls, wondering if that means the data didn't bind?

I am seeing the column headers however, just not any rows. I must mention as well, I don't have any ID fields in my data as I'm using a temp table from a SQL view.

function populateGrid(search) {
    $("#grdAttributes").kendoGrid({
        dataSource: {
            transport: {
                read: {
                    url: "http://127.0.0.2:6080/arcgis/rest/services/WW/WW2/MapServer/exts/RestSOE/Search%20Query?columnName=" + search.columnName + "&operand=" + search.operand + "&searchVal=" + search.searchVal + "&f=",
                    dataType: "json",
                    type: 'GET'
                }
            },
        },
        serverPaging: true,
        serverSorting: true,
        serverFiltering: true,
        scrollable: true,
        height: 150

    });
    $("#grdAttributes").data().kendoGrid.dataSource.view()
};

If I continue through the error in VS2012 I do see the column headers in the grid. Just no row data. (sample JSON below:)

 -[{
     -"Address": "PO BOX 20",
     -"City": "HAVENWOOD",
     -"Location": "",
     -"Name 1": "UNIVERSITY",
     -"Name 2": "",
     -"Street": "NEY AVE",
     -"Street Num": "16",
     -"Legacy ROD Num": null - "Repeat Client": "Y" -
 }, ...

Here is start of the error:

`Unhandled exception at line 11, column 6788 in
http://--------:51392/WW/js/kendo.web.min.js 0x800a139e - JavaScript
runtime error: Invalid template:'<tr data-uid="#=data.uid#"
role='row'><td  role='gridcell'>#=data.Account
Num==null?'':data.Account Num#</td><td 
role='gridcell'>#=data.address==null?'':data.address#</td><td 
role='gridcell'>#=data.Arb Location==null?'':data.Location#</td><td 
role='gridcell'>#=data.WNum==null?'':data.Num#</td><td`

Hopefully that's enough info to get some feedback. [banging my head]. Thanks in advance!

Trying to figure out the Kendo world and having an issue with a grid set to a json array datasource.

Error is "JavaScript runtime error: Invalid template: <tr
data-uid="#=data.uid#" role='row'><td  role='gridcell'>#=data.Account
Num==null?'':data.Account Num#</td>...".

I notice that in this error I see nulls, wondering if that means the data didn't bind?

I am seeing the column headers however, just not any rows. I must mention as well, I don't have any ID fields in my data as I'm using a temp table from a SQL view.

function populateGrid(search) {
    $("#grdAttributes").kendoGrid({
        dataSource: {
            transport: {
                read: {
                    url: "http://127.0.0.2:6080/arcgis/rest/services/WW/WW2/MapServer/exts/RestSOE/Search%20Query?columnName=" + search.columnName + "&operand=" + search.operand + "&searchVal=" + search.searchVal + "&f=",
                    dataType: "json",
                    type: 'GET'
                }
            },
        },
        serverPaging: true,
        serverSorting: true,
        serverFiltering: true,
        scrollable: true,
        height: 150

    });
    $("#grdAttributes").data().kendoGrid.dataSource.view()
};

If I continue through the error in VS2012 I do see the column headers in the grid. Just no row data. (sample JSON below:)

 -[{
     -"Address": "PO BOX 20",
     -"City": "HAVENWOOD",
     -"Location": "",
     -"Name 1": "UNIVERSITY",
     -"Name 2": "",
     -"Street": "NEY AVE",
     -"Street Num": "16",
     -"Legacy ROD Num": null - "Repeat Client": "Y" -
 }, ...

Here is start of the error:

`Unhandled exception at line 11, column 6788 in
http://--------:51392/WW/js/kendo.web.min.js 0x800a139e - JavaScript
runtime error: Invalid template:'<tr data-uid="#=data.uid#"
role='row'><td  role='gridcell'>#=data.Account
Num==null?'':data.Account Num#</td><td 
role='gridcell'>#=data.address==null?'':data.address#</td><td 
role='gridcell'>#=data.Arb Location==null?'':data.Location#</td><td 
role='gridcell'>#=data.WNum==null?'':data.Num#</td><td`

Hopefully that's enough info to get some feedback. [banging my head]. Thanks in advance!

Share Improve this question edited Oct 16, 2013 at 23:11 Mike-O 8941 gold badge11 silver badges16 bronze badges asked Oct 16, 2013 at 22:15 ripsinripsin 2732 gold badges7 silver badges19 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

It's hard to tell pletely, but it looks like the generated template is having problems because you have spaces in your data field names, for example:

'Account Num', and in the template it is trying to access "data.Account Num" which of course, will not work.

Set your data to have no spaces to begin with to see if that actually is the problem. If it is the problem, another solution (if you wanted to keep the spaces) would be to manually enter the columns instead of letting it auto-generate it.

... To deal with spaces:

First set your datasource scheme up with fields like:

schema: {
    data: "Data",
    model: {
        fields: {
            "Name": { type: "string" },
            "Account Num": { type: "string" }
        }
    }
}

Then for your columns, define them with template like so:

columns: [
   {
      field: "Name",
      title: "Name",
      template: "#=data['Name']==null?'':data['Name']#"
   },
   {
      field: "Account Num",
      title: "Account Num",
      template: "#=data['Account Num']==null?'':data['Account Num']#"
   }
]

What you originally had was kendo trying to generate the template itself, but it was trying to access

data.Account Num

which of course wouldn't work in javascript, so instead, you can manually define the template of each column to instead access

data['Account Num']

which will work properly and hopefully get the result you are looking for.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743914671a4528978.html

相关推荐

  • sql - KendoGrid JavaScript runtime error: Invalid template - Stack Overflow

    Trying to figure out the Kendo world and having an issue with a grid set to a json array datasource.Err

    2天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信