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

Connecting to local data file for grid not working

2 Answers 185 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 24 Feb 2015, 06:44 AM
I'm trying to connect to my local JSON file, but it's not working. I thought I'd start with the basics and copy the demo XML to a local file, but that's still not working. Just wondering if anyone can spot why it won't work locally? I'm using the basic grid setup code.

$("#grid").kendoGrid({
    dataSource: {
        type: "odata",
        transport: {
            read: "app/js/swagger-test.xml"
        },
        pageSize: 20
    },
    height: 550,
    groupable: true,
    sortable: true,
    pageable: {
        refresh: true,
        pageSizes: true,
        buttonCount: 5
    },
    columns: [{
        field: "ContactName",
        title: "Contact Name",
        width: 200
    }, {
        field: "ContactTitle",
        title: "Contact Title"
    }, {
        field: "CompanyName",
        title: "Company Name"
    }, {
        field: "Country",
        width: 150
    }]
});

There are no errors showing, but neither is the data. If I change it to point to my JSON file and change the type to json, I get an undefined error.

Thanks for any help.

2 Answers, 1 is accepted

Sort by
0
Paul
Top achievements
Rank 1
answered on 24 Feb 2015, 06:51 AM
Had a thought, it maybe just best to post my JSON that isn't working, as this is what I'm ultimately trying to solve!

$("#grid").kendoGrid({
    dataSource: {
        type: "json",
        transport: {
            read: "app/js/swagger-test.json"
        },
        pageSize: 20
    },
    height: 550,
    groupable: true,
    sortable: true,
    pageable: {
        refresh: true,
        pageSizes: true,
        buttonCount: 5
    },
    columns: [{
        field: "name",
        title: "Contact Name",
        width: 200
    }]
});

And the error I get in console is: "Uncaught TypeError: undefined is not a function".

Some sample JSON:


"parameters": [
                    {
                        "name": "latitude",
                        "in": "query",
                        "description": "Latitude component of location.",
                        "required": true,
                        "type": "number",
                        "format": "double"
                    },
                    {
                        "name": "longitude",
                        "in": "query",
                        "description": "Longitude component of location.",
                        "required": true,
                        "type": "number",
                        "format": "double"
                    }
                ],
0
Kiril Nikolov
Telerik team
answered on 25 Feb 2015, 02:32 PM

Hello Paul,

I guess you are missing the schema.data configuration stating where the array with values should be found. Please check the following example that I believe will be helpful:

http://dojo.telerik.com/iTACa

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Data Source
Asked by
Paul
Top achievements
Rank 1
Answers by
Paul
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Share this question
or