JSON DataSource Model

4 posts, 1 answers
  1. Chris
    Chris avatar
    3 posts
    Member since:
    Feb 2015

    Posted 18 Aug Link to this post

    Example: http://jsfiddle.net/rqqw5v7x/

    How does one grab just the data within the "Customers:" array from JSON?

    Abridged version of what comes from http://northwind.servicestack.net/customers.json :

     

    {"Customers":[
    {"Id":"ALFKI","CompanyName":"Alfreds Futterkiste","ContactName":"Maria Anders","ContactTitle":"Sales Representative","Address":"Obere Str. 57","City":"Berlin","PostalCode":"12209","Country":"Germany","Phone":"030-0074321","Fax":"030-0076545"},
    {"Id":"ANATR","CompanyName":"Ana Trujillo Emparedados y helados","ContactName":"Ana Trujillo","ContactTitle":"Owner","Address":"Avda. de la Constitución 2222","City":"México D.F.","PostalCode":"05021","Country":"Mexico","Phone":"(5) 555-4729","Fax":"(5) 555-3745"}
    "}],"ResponseStatus": {}}

     

  2. Answer
    Patrick
    Admin
    Patrick avatar
    171 posts

    Posted 18 Aug Link to this post

    Hi Chris,

    In order to get Customers from the Json, you must add the schema.data configuration. 
    Here is a snippet:
    var dsCustomer = new kendo.data.DataSource({
                transport: {
                    read: {
                        url: "http://northwind.servicestack.net/customers.json",
                        dataType: "json"
                    }
                },
                schema: {
                    data: "Customers",
                    ...
                }
            });

    Please take a look at this Kendo UI Dojo by Progress which uses that dataSource in a Kendo Grid.  

    I hope this helps!

    Regards,
    Patrick
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  3. Kendo UI is VS 2017 Ready
  4. Chris
    Chris avatar
    3 posts
    Member since:
    Feb 2015

    Posted 30 Sep in reply to Patrick Link to this post

    I hope this helps!

    It does help. Thank you!

  5. Patrick
    Admin
    Patrick avatar
    171 posts

    Posted 30 Sep Link to this post

    Hi Chris,

    Glad everything is working well!

    Regards,
    Patrick
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
Back to Top
Kendo UI is VS 2017 Ready