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

How to read in local a JSON File ?

5 Answers 335 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
ABDELLALI
Top achievements
Rank 1
ABDELLALI asked on 11 Jan 2019, 03:14 PM

Hi,

After pacing the web and lots of forums, I still can not read a JSON file locally.

Can anyone help me ?

Here is my basic file for my tests, and my .json file on the right.

Forgive me if there are many mistakes. I start with Kendo UI

Thank you in advance for your precious help

5 Answers, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 15 Jan 2019, 08:44 AM
Hello Abdellali,

Attached you will find a small sample based on the snippets from the screenshot sent. While running it locally, you will notice that it populates the Scheduler widget with the two events from the JSON file in question. What I have altered in the Scheduler configuration is that I have included the full name of the JSON file (​api/products.json) and I have properly mapped the Id field:
model: {
    id: "Id",
    fields: {
        Id: { type: "number" },
...

Regards,
Veselin Tsvetanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
ABDELLALI
Top achievements
Rank 1
answered on 17 Jan 2019, 01:00 PM

Hello and thank you for your support.

I made the changes taking care to copy your method but it doesn't work either.

Also, I tested with your files and it doesn't work either. It's written the same thing in the console. Something like :

Access to XMLHttpRequest at 'file:///C:/Users/r.rousselle/Documents/NetBeansProjects/Agenda/public_html/api/products.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

Here are my files attached

0
Veselin Tsvetanov
Telerik team
answered on 21 Jan 2019, 08:22 AM
Hi Abdellali,

The error observed would be present if you try to run the index.html file directly in the browser (by double clicking it). Instead, you will need to host it on a server and open the server address in the browser. I personally use the http-server npm package run such examples. Here you will find a short video of running the sample sent. 

Note also, that in order to display the event passed from the JSON, you will need to set the ​allDaySlot: configuration option of the Scheduler to trueallDaySlot: true. This is needed because the event is configured to be an all day event ("IsAllDay": true).

Regards,
Veselin Tsvetanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
ABDELLALI
Top achievements
Rank 1
answered on 21 Jan 2019, 10:04 AM

Hello and thank you for your relevant remark.

I restarted my page from a local URL and it works!

I still have a problem for the moment that your subscribers do not find either at this link:

https://www.telerik.com/forums/bug---cancel-button-in-event-edit-window-is-removing-event#jwfBEKUo2kGygbXGcClDUA

Still Thank you ;)

0
Veselin Tsvetanov
Telerik team
answered on 23 Jan 2019, 08:05 AM
Hello Abdellali,

As far as I can see in the forum thread in question, you have resolved the issue faced. Should you have any other questions, please do not hesitate to contact us.

Regards,
Veselin Tsvetanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Scheduler
Asked by
ABDELLALI
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
ABDELLALI
Top achievements
Rank 1
Share this question
or