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

Simple Json connection not working

1 Answer 97 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 24 Sep 2013, 09:28 AM
Hello,
I am trying to familiarise myself with the kendo ui dataSource, I have never before used JSON and have constructed the following using your documentation:

Html:
<!doctype html>
<html>
    <head>
        <title>Kendo UI Web</title>
        <link href="styles/kendo.common.min.css" rel="stylesheet" />
        <link href="styles/kendo.default.min.css" rel="stylesheet" />
        <script src="js/jquery.min.js"></script>
        <script src="js/kendo.web.min.js"></script>
    </head>
    <body>
        <div id="grid"></div>
        <script>
        $(document).ready(function () {
            var myDataSource = new kendo.data.DataSource({
                transport: {
                    read: {
                        url: "people.json",
                        dataType: "json"
                    }
                }
            });
 
            $("#grid").kendoGrid({
                dataSource: myDataSource,
                    columns: [
                    {
                        field: "firstName",
                        title: "First Name"
                    },
                    {
                        field: "lastName",
                        title: "Last Name"
                }]
            });
 
        });
 
    </script>
    </body>
</html>
Json File:
{
    "people": [
        { "firstName":"John" , "lastName":"Doe" },
        { "firstName":"Anna" , "lastName":"Smith" },
        { "firstName":"Peter" , "lastName":"Jones" }
    ]
}
The grid doesn't load any data, all I see are the headers.

I have tried this using simply HTML and a JSON file, I have also tried this in Visual Studio.

Any help would be appreciated,
Andrew.

1 Answer, 1 is accepted

Sort by
0
Andrew
Top achievements
Rank 1
answered on 24 Sep 2013, 12:24 PM
I needed to add:
schema : {
                    data: "people"
                }
What's more, Google chrome doesn't display the table data. Firefox and IE do, perhaps something to do with how my browser is configured on this work machine.
Tags
Data Source
Asked by
Andrew
Top achievements
Rank 1
Answers by
Andrew
Top achievements
Rank 1
Share this question
or