Kendo SaveAs removes whitespaces

7 posts, 0 answers
  1. arjun
    arjun avatar
    2 posts
    Member since:
    Mar 2018

    Posted 15 Mar Link to this post

    Hi,

    On the click of a button, I am saving the content (json) to a file. The problem I am facing is that the file has whitespaces stripped out.

    saveContent : function () {
     var format = "data:application/json";
     var fileName = "content.json";
     var dataURI = format + "," + this.content;
     
     kendo.saveAs(
     {
       dataURI: dataURI,
       fileName: fileName
     }
    );
    }

    For e.g. if the json is something like this

    {"productDescription" : "Bag of wheat 15 kilogram"}

     

    the content of file is the following. How can I make sure that saved file has whitespaces preserved?

    {"productDescription" : "Bagofwheat15kilogram"}
  2. arjun
    arjun avatar
    2 posts
    Member since:
    Mar 2018

    Posted 15 Mar Link to this post

    Turns out, if its data:application/json, then it removes all the whitespaces.

    If its data:text/plain, then it preserves the whitespaces.

  3. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    795 posts

    Posted 19 Mar Link to this post

    Hello Arjun,

    Here you will find a small Dojo sample, which replicates the described scenario. You will notice, that the exported JSON properly preserves the white spaces in its values.

    May I ask you to modify the above so it reproduces the issue observed at your end and send it back to us? This way we will be able to troubleshoot the problem locally and to provide you with the most appropriate assistance on this case.

    Regards,
    Veselin Tsvetanov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  4. reb
    reb avatar
    3 posts
    Member since:
    Feb 2018

    Posted 27 Mar Link to this post

    Hi I have a similar problem.The issue is indentation apeears ok in visual studio but in editor it appears in a line with spaces 

  5. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    795 posts

    Posted 29 Mar Link to this post

    Hi Reb,

    I am not quite sure if I understand correctly the issue faced. If case you are not seeing the proper indention in some specific text editor, note that it might be an application specific issue.

    If this is not the case, could you please, prepare and send us a small Dojo sample replicating the problem? 

    Regards,
    Veselin Tsvetanov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. reb
    reb avatar
    3 posts
    Member since:
    Feb 2018

    Posted 29 Mar in reply to Veselin Tsvetanov Link to this post

    Hi ,

    Is there a kendo UI element that I can use to display json file with indentation and even maybe that allows to collapse and expand sub elements.

    Also is there a way to export to Json as we have export to PDF ?

     

    Will share dojo example soon

  7. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    795 posts

    Posted 02 Apr Link to this post

    Hello Reb,

    I am afraid that none of the Kendo widgets would allow you to load and display a JSON file. Nevertheless, you could write or paste a JSON formatted text in a Kendo Editor.

    As per the export question, the Kendo Spreadsheet can perform such action. Nevertheless, a visualized JSON in an Editor widget could not be exported as JSON file.

    In case you have any other questions, which are not directly related to the initial topic of the current thread ("Kendo SaveAs removes whitespaces"), I would recommend you to open a separate thread for each of them. This way we will be able to keep the thread focused and to provide you with the most appropriate assistance on each case.

    Regards,
    Veselin Tsvetanov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top