0

I am able to parse and extract the data using KendoUI when JSON is in the form { "data" :[ { }, { }, { } ] }

But I am unable to do the same when JSON is in the form [ { }, { }, { } ]

I am trying with the following code:

var dataSourceSeam = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "data/address.json",
                    dataType: 'json'
                }
            }

            ,schema:{
                data : "data",
                size:"count"

            }

        });
Saty
  • 1,068
  • 11
  • 24

1 Answers1

2

Saying data : "data" you are saying that expect the JSON array in a field called data.

Try:

var dataSourceSeam = new kendo.data.DataSource({
    transport: {
        read: {
            url: "data/address.json",
            dataType: 'json'
        }
    }
};

instead.

OnaBai
  • 40,767
  • 6
  • 96
  • 125
  • Does defining url as local address and defining it as an online Webservice url cause any difference?? – Saty Dec 27 '12 at 10:28
  • No when it refers to the topic of your question. But it makes difference for the browser since it might imply [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing). **BUT** as I said, this is not the topic of your question since you were asking about why using `data: "data"`. – OnaBai Dec 27 '12 at 11:57
  • Yes it worked perfectly..... but when i Am replacing the URL with the actual online JSON url.... it shows some error like...... not allowed by access-control-allow-origin.jquery. I know why this error, But i dont know its Workaround!! – Saty Dec 28 '12 at 09:07
  • Different question :-( Check [this](http://stackoverflow.com/questions/9327218/access-control-allow-origin-not-allowed-by) – OnaBai Dec 28 '12 at 09:50