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

help with local JSON

4 Answers 109 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Scott Buchanan
Top achievements
Rank 1
Scott Buchanan asked on 07 Nov 2015, 04:26 AM

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

 

 


4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 11 Nov 2015, 09:00 AM
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!
 
0
Scott Buchanan
Top achievements
Rank 1
answered on 11 Nov 2015, 06:12 PM

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

0
Accepted
Daniel
Telerik team
answered on 13 Nov 2015, 03:26 PM
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!
 
0
Scott Buchanan
Top achievements
Rank 1
answered on 14 Nov 2015, 02:05 AM

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

Tags
Data Source
Asked by
Scott Buchanan
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Scott Buchanan
Top achievements
Rank 1
Share this question
or