This is a migrated thread and some comments may be shown as answers.

Jsonp datasource : Invalid label d:

3 Answers 111 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Tycho
Top achievements
Rank 1
Tycho asked on 26 Jun 2012, 07:01 AM
Hi all,

Hope someone can point me in the right direction because this is driving me crazy...

I'm trying to bind a grid to an asp.net WCF service on another domain using jsonp.

The data returned by the WCF service is like localData in the code below. Databinding succeeds when binding the grid to the localData, but if i change to the raDataSource it gives an error. In firebug it says:  "invalid label {"d":[etc " . 
 
I found a number of posts on the forum saying to add schema { data: "d" } to the datasource but i keep getting the same error.
var localData = {"d":[{"__type":"type1","ClassNbr":"5","SiteName":"Name1","Train":"Train1"},{"__type":"type1","ClassNbr":"4","SiteName":"Name2","Train":"Train2"}]};
 
var raDataSource = new kendo.data.DataSource({
            type: "odata",
            transport: {
                read: {
                    type: "GET",
                    contentType: "application/json; chartset=utf-8",
                    url: dataUrl,
                    dataType: "jsonp",
                    jsonp: true,
                    jsonpCallback: 'callback'
                }
            },
            data: {
              siteID: si,
              cceMode: mode,
              endDate: encodeURIComponent(endDate),
              Accept: "application/json"
            },
            error: function (e) {
                alert("Error: " + e);
            },
            schema: {
                data: "d"
            },
            model: {
                    fields: {
                        SiteName: { type: "string" },
                        Train: { type: "string" }
                    }
            }
    });
 
     $("#grid").kendoGrid({
        dataSource: raDataSource  ,
        height: 360,
        columns: [
            {   field:"SiteName"    },
            {   field:"Train"   },
        ],
        dataBound: function() { alert('bound');},
    });

Any idea's?

Kind regards,
Tycho

3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 26 Jun 2012, 07:09 AM
Hello Tycho,

Here is an example of binding to OData service using JSONP as the service is in another domain:
http://demos.kendoui.com/web/grid/remote-data.html

Greetings,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Tycho
Top achievements
Rank 1
answered on 26 Jun 2012, 07:18 AM
Hello Nikolay,

Thanks, I've seen the example, but that didn't help me getting past the invalid label error..
0
Tycho
Top achievements
Rank 1
answered on 27 Jun 2012, 10:54 AM
Turns out there was an error in the WCF service....I've modified the service and the datasource now seems to load data, but for some reason it won't display it in the grid.

Datasource:
var ds = new kendo.data.DataSource({
    type: "odata",
    transport: {
        read: {
            url: dataUrl,
            dataType: "jsonp",
            jsonp: "callback",
            jsonpCallback: 'DataCallBack'
        }
    },
    error: function (e) {
            alert("Error2: " + e);
    },
    serverPaging: true,
    pageSize: 10
});

Using firebug i can see the data returned by the service so a request is made: 
DataCallBack( [{"RunStatusTag":null,"Service":"Charge Pump","SiteName":"FCCU"},{"RunStatusTag":null,"Service":"Charge Pump 2","SiteName":"FCCU2"},{"RunStatusTag":null,"Service":"Charge Pump3","SiteName":"FCCU3"}] );

Grid:
$("#grid2").kendoGrid({
    dataSource:ds,
    dataBound: function(e) {
         alert("Bound2 " + e);
    },
    columns: [
            {   field:"SiteName",title: "Plant/Facility" },
            {   field:"Service",title: "Service"    }
    ]
});

Any idea's?
Tags
Data Source
Asked by
Tycho
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Tycho
Top achievements
Rank 1
Share this question
or