How to read in local a JSON File ?

6 posts, 0 answers
  1. ABDELLALI
    ABDELLALI avatar
    5 posts
    Member since:
    Apr 2015

    Posted 11 Jan 2019 Link to this post

    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

  2. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1220 posts

    Posted 15 Jan 2019 Link to this post

    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.
  3. ABDELLALI
    ABDELLALI avatar
    5 posts
    Member since:
    Apr 2015

    Posted 17 Jan 2019 in reply to Veselin Tsvetanov Link to this post

    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

  4. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1220 posts

    Posted 21 Jan 2019 Link to this post

    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.
  5. ABDELLALI
    ABDELLALI avatar
    5 posts
    Member since:
    Apr 2015

    Posted 21 Jan 2019 Link to this post

    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 ;)

  6. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1220 posts

    Posted 23 Jan 2019 Link to this post

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