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

How to design schema model for this JSON response?

1 Answer 178 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Jegan
Top achievements
Rank 1
Jegan asked on 02 Jul 2012, 08:03 PM
Hello Telerix team,

I am in the process of evaluating Kendo UI for my apps and trying to understand the do's and dont's for our business case. One of the cases which is quite possible in my application is that the JSON can be of the following format.

I am not able to derive a equivalent data model to make the Kendo Grid consume the same. 

Here is the JSON response that is returned as part of my transport: url.

My requirement is to consume the data in the ItemList using the KendoGrid. How to derive a schema model for the same.

{
  "d" : [{
    "__metadata": {
      "uri": "http://localhost/TestService/TestService.svc/Order('4345')", 
      "type": "DataModels.OrderDetail"
    }, 
    "ItemList": [{
      "__metadata": {
        "uri": "http://localhost/TestService/TestService.svc/Item('1')", 
        "type": "DataModels.Item"
      }, 
      "ItemId": "1", 
      "Name": "TestItem", 
      "Rate": "19.00", 
      "Quantity": "3"
    }]
  }]
}

Thanks in advance!

1 Answer, 1 is accepted

Sort by
0
Phil Boudreau
Top achievements
Rank 2
answered on 20 Jul 2012, 01:35 AM
I had the same problem; just figured it out at this moment...

You need to add the schema "attribute" to your datasource. Mine looks something like this:

dataSource: {
 transport: {
  read: {
   url: "http://somedomain/somedataservice.svc/somefunction",
   dataType: "json"
  }
 },
 schema: {
  data: "d"
 }
},

 

The important part is the schema thing.

Hope this helps!
Tags
Data Source
Asked by
Jegan
Top achievements
Rank 1
Answers by
Phil Boudreau
Top achievements
Rank 2
Share this question
or