Need help mapping with remote Json

2 posts, 0 answers
  1. Daniel
    Daniel avatar
    36 posts
    Member since:
    Apr 2009

    Posted 17 Sep 2012 Link to this post

    I am not sure how I should map this data to get it to the datasource. I have read the docs but am not sure how to map this data.  If I change the url back to the demo.kedoui.com/service the data: event fires and binds ok.  With my url I get error event with msg error, but I do not see any data returned or how to fix this so the data is mapped correctly and the data event fires using my url json service.

    Thanks

    Data:
    {"__entityModel":"People","__COUNT":3,"__SENT":3,"__FIRST":0,"__ENTITIES":[{"__KEY":"27","__STAMP":11,"ID":27,"firstName":"dan","lastName":"qqqq"},{"__KEY":"26","__STAMP":14,"ID":26,"firstName":"dan","lastName":"rrrr"},{"__KEY":"25","__STAMP":13,"ID":25,"firstName":"dan","lastName":"eeee"}]}
    Code:
       $(document).ready(function () {
                       //var crudServiceBaseUrl = "http://demos.kendoui.com/service",
                      //  var crudServiceBaseUrl = "http://127.0.0.1:8081/rest",
    var dataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "http://127.0.0.1:8081/rest/People",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json"
                }
            },
            schema: {
                data: function (data) {
                    alert("got data")
                    alert(data);   /*Data Return Successfully*/
                    return data;
                }
            },
            error: function (e) {
                debugger;
                alert("Error");
            },
            change: function (e) {
                alert("Change");
            },
            requestStart: function (e) {
                debugger;
                alert("Request Start");
            }
        });
     
                        $("#grid").kendoGrid({
                            dataSource: dataSource,
                            pageable: true,
                            height: 400,
                            toolbar: ["create"],
                            columns: [
                                "firstName",
                                   "lastName",
                                { command: ["edit", "destroy"], title: " ", width: "210px" }],
                            editable: "inline"
                        });
                    });
  2. Christopher Tallos
    Christopher Tallos avatar
    12 posts
    Member since:
    Sep 2009

    Posted 30 Nov 2012 Link to this post

    Hi Daniel,

    Did you ever figure this out, if so, can you post the solution?
Back to Top