Custom data in template

14 posts, 0 answers
  1. Gensys Development
    Gensys Development avatar
    9 posts
    Member since:
    Nov 2012

    Posted 07 Mar 2014 Link to this post

    Hi,

    Is it possible to use custom data in the upload template?
    In the success event i can do something like:

    success: function (e) {
        e.files[0].DocumentID = e.response;
    }

    Then i would like to use this DocumentID in a template to render a control and attach this value to it.
  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2159 posts

    Posted 11 Mar 2014 Link to this post

    Hello Jack,


    At the moment passing custom data to the template is not supported out of the box.
    I am not sure that I exactly understand the current scenario. Do you want to render a widget in the uploaded file template? Please share some additional details, so I could assist you further.

    Regards,
    Dimiter Madjarov
    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. Gensys Development
    Gensys Development avatar
    9 posts
    Member since:
    Nov 2012

    Posted 12 Mar 2014 Link to this post

    I would like to change the file names after the files are uploaded.

    So after the file is succesfully uploaded and added to the upload-files list it should render something like a 
    <input type="text" data-documentid=[id-from-result]>  for each file.

    I could add this <input type='text'> to the template, but then i dont have the documentId which i need to map the file name description to the actual file.

    When the form is submitted i can change the file descriptions of the uploaded files.





  5. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2159 posts

    Posted 14 Mar 2014 Link to this post

    Hello Jack,


    Is the following approach for receiving metadata from the save handler suitable for the current scenario? For example you could return a JSON result containing the new file name and/or id. Then in the success event handler you could access the JSON via the e.response parameter (as demonstrated in the documentation example) and use the old file name to find the file list item and manipulate it as you like.
    E.g.
    return Json(new { newFileName = "file name" }, "text/plain");

    function success(e) {
        var oldName = e.files[0].name;
        var newName = e.response.newFileName;
     
        var listItem = this.wrapper.find("[title='" + oldName + "']").closest("li.k-file");
    }

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Gensys Development
    Gensys Development avatar
    9 posts
    Member since:
    Nov 2012

    Posted 21 Mar 2014 in reply to Dimiter Madjarov Link to this post

    Thanks for your suggestion, but the only problem here is that the filename alone is not unique. Is there a way to get a full path?
  7. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2159 posts

    Posted 24 Mar 2014 Link to this post

    Hello Jack,


    Retrieving the full path is not allowed in JavaScript for security reasons.

    Nevertheless you are correct that at the moment there is no absolutely reliable way to distinguish files with the same name in the list. We are considering to assign a unique guid to each file and render it as a data attribute to the list items in the list.
    E.g.
    <li class="k-file" data-uid="..."></li>

    The guid could also be part of the e.files collection passed to the widget events. This way each file will be easily identified. Will this behavior be suitable for the current case?

    I am looking forward to hear your opinion.

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  8. Gensys Development
    Gensys Development avatar
    9 posts
    Member since:
    Nov 2012

    Posted 26 Mar 2014 in reply to Dimiter Madjarov Link to this post

    Hi,

    Yes a guid to identify each file would be great.
  9. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2159 posts

    Posted 26 Mar 2014 Link to this post

    Hello Jack,

    I am glad that you liked the suggested resolution. I have logged this feature for development.

    I will update the current forum thread with more information on the topic, when the feature is live in our internal builds.

    Have a great day!

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  10. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2159 posts

    Posted 03 Apr 2014 Link to this post

    Hi Jack,


    I am glad to inform you that this feature have been implemented and it will be available in the next internal build.

    I wish you a great day!

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  11. Gensys Development
    Gensys Development avatar
    9 posts
    Member since:
    Nov 2012

    Posted 07 Apr 2014 Link to this post

    Hi,

    That is great, thank you!
  12. Karthik
    Karthik avatar
    3 posts
    Member since:
    Mar 2015

    Posted 17 Apr 2015 Link to this post

    Hi 

    I want to do the same functionality after onselect event before uploading the file. I am using autoupload(false) in ASync mode. Can I please know the possibilities?

    Thanks

    Karthik

     

  13. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2159 posts

    Posted 20 Apr 2015 Link to this post

    Hello Karthik,

    Could you elaborate what exactly is required in the current scenario so I could provide assistance? I am looking forward to hearing from you.

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  14. Karthik
    Karthik avatar
    3 posts
    Member since:
    Mar 2015

    Posted 20 Apr 2015 in reply to Dimiter Madjarov Link to this post

    Hi Dimiter

    Thanks for your response...

    I am building a page with ASP.NET MVC(Razor) using Kendo Upload controls. I have to accomplish the following functionality.

    1. This is a form with many telerik controls along with 3 Kendo Upload controls.

    2. I have added the upload controls with Async mode But made the auto upload false.

    3. I have to make the "Upload Files" button hidden and to initiate the file upload process for all 3 upload controls simultaneously using form submit button along with other fields in the form.

    4. I also want to customize the grid display of selected files with a custom field called display name. something like                                 [ File Name]           [Display Name]                [Remove Icon]

    5. I want to implement the "Remove all" button to clear all uploaded files before they initiate upload if required.

    Please help.

    Regards...

    Karthik

     

     

     

     

  15. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2159 posts

    Posted 21 Apr 2015 Link to this post

    Hello Karthik,

    The asynchronous version of the Upload widget is not intended to be used in a form. The files will be submitted in a separate ajax requests and not with the other form elements.

    Regarding the custom display name field, where does it come from?

    The "remove all" functionality is not available out of the box, but it could be easily achieved by iterating the files in the list and manually triggering the click event of their remove buttons via jQuery.

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready