help with local JSON

5 posts, 1 answers
  1. Scott Buchanan
    Scott Buchanan avatar
    38 posts
    Member since:
    Dec 2008

    Posted 06 Nov 2015 Link to this post

    I am working with AppBuilder.  Created a new app using the Kendo UI drawer navigation template.

    I have a JSON file (originally in data folder but now at root) that looks like this:

    [
        {
            "Name": "Breakfast & Registration",
            "Location": "",
            "Start": "7:30 am",
            "End": "8:30 am",
            "Track" : "",
            "Sequence" : 1
        },
        {
            "Name": "Creating a Successful Audit",
            "Location": "",
            "Start": "8:30 am",
            "End": "9:30 am",
            "Track" : "Auditing",
            "Sequence" : 2
        },
        {
            "Name": "The Health Insurance and Portability Act",
            "Location": "",
            "Start": "8:30 am",
            "End": "9:30 am",
            "Track" : "Compliance",
            "Sequence" : 3
        }
    ]

    app.js contains models for each of the views.  I am working on the agenda view:

    // create an object to store the models for each view
    window.APP = {
        models: {
            home: {
                    title: 'Home'
                },
            survey: {
                    title: 'Survey'
                },
            agenda: {
                    title: 'Agenda',
                    ds: new kendo.data.DataSource({
                        transport: {
                            read: {
                                url: "agendaSmall.json",
                                dataType: "json"
                            }
                        }
                        //ds: new kendo.data.DataSource({
                        //data: [{ id: 1, name: 'Bob' }, { id: 2, name: 'Mary' }, { id: 3, name: 'John' }]
                    }),
                    //alert: function(e) {
                    //    alert(e.data.Name);
                    //}
                }
        }
    };

    agenda.html should display these items, but does not

    <div data-role="view" data-title="Agenda" data-layout="main" data-model="APP.models.agenda">
      <ul data-role="listview" data-style="inset" data-template="agendaTemplate" data-bind="source: ds"></ul>
    </div>
     
    <script type="text/x-kendo-template" id="agendaTemplate">
      <a data-bind="click: alert">#: Name #</a>
    </script>

    I have defined the datasource about 10 different ways, based on posts in this and other forums.

    I have plugged the JSON directly into the model, and that does display correctly, but is not suitable.

     What am I missing?

    Thanks,
    Scott

     

     


  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 11 Nov 2015 Link to this post

    Hello Scott,

    The dataSource configuration seems correct. Could you check what is the response in the network tab of the developert tools for the agendaSmall.json file?

    Regards,
    Daniel
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Scott Buchanan
    Scott Buchanan avatar
    38 posts
    Member since:
    Dec 2008

    Posted 11 Nov 2015 in reply to Daniel Link to this post

    Daniel,

     Thanks for the feedback.  I had taken a look at the network activity and there was nothing.  I expected a 404 or something but it seems that it never attempted to read the file.  For now, I just copied the JSON into the data source and continued coding the views.

    There is an error in the console: "Failed to clear temp storage: It was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources."....

    Scott

  5. Answer
    Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 13 Nov 2015 Link to this post

    Hello again Scott,

    In that case could you provide a sample project that demonstrates the issue? I tested with the code that you provided but the data was loaded correctly.

    Regards,
    Daniel
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Scott Buchanan
    Scott Buchanan avatar
    38 posts
    Member since:
    Dec 2008

    Posted 13 Nov 2015 in reply to Daniel Link to this post

    Daniel,

     I had some items commented out in the dataSource declaration, and after removing them this is reading the JSON file just fine.  Thank you for your attention.

     

    Scott

Back to Top
Kendo UI is VS 2017 Ready