Connecting to local data file for grid not working

3 posts, 0 answers
  1. Paul
    Paul avatar
    2 posts
    Member since:
    Feb 2015

    Posted 24 Feb 2015 Link to this post

    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. Paul
    Paul avatar
    2 posts
    Member since:
    Feb 2015

    Posted 24 Feb 2015 in reply to Paul Link to this post

    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"
                        }
                    ],
  3. Kendo UI is VS 2017 Ready
  4. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2564 posts

    Posted 25 Feb 2015 Link to this post

    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!
     
Back to Top