Adding an Id to selected items

8 posts, 0 answers
  1. Cosmin
    Cosmin avatar
    7 posts
    Member since:
    Jul 2013

    Posted 07 Mar 2014 Link to this post

    Hello,
    I'm using the sync upload widget.
    I would like to be able to add an a custom unique id attribute to the inputs of the files selected.
    Unfortunately, the inputs are created after the "Selected" event.
    Is there any way i can achieve this?
  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 11 Mar 2014 Link to this post

    Hi Cosmin,


    You could add a setTimeout call in the select event in order to access the hidden inputs of the Upload widget.
    E.g.
    @(Html.Kendo().Upload()
        .Name("files")
        .Events(e => e.Select("select"))
    )

    function select(e) {
        setTimeout(function () {
            var upload = $("#files").data("kendoUpload");
            var inputs = upload.wrapper.find("input");
        });
    }


    Regards,
    Dimiter Madjarov
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Cosmin
    Cosmin avatar
    7 posts
    Member since:
    Jul 2013

    Posted 11 Mar 2014 Link to this post

    Thank you for the response, but after some analyzing i have found another problem.
    I see that for all the files selected only 1 input is created. Let me explain what i am trying to do, maybe it will make more sense. I need to be able to add files( a file name can exist more than once) and then be able to remove them. To accomplish this, i need a custom Id so i know which file i am deleting. I have already implemented a custom list and remove action, all i need to know is how can i delete a file from the widget using some kind of unique identifier.
  5. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 11 Mar 2014 Link to this post

    Hi Cosmin,


    You could use the template functionality of the Upload widget, set a custom template and put some kind of unique identifier inside.
    E.g.
    @(Html.Kendo().Upload()
        .Name("files")
        .TemplateId("fileTemplate")
    )

    <script id="fileTemplate" type="text/x-kendo-template">
        <h4 data-uid="#=kendo.guid()#">Name: #=name#</h4>
    </script>


    Regards,
    Dimiter Madjarov
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

  6. Cosmin
    Cosmin avatar
    7 posts
    Member since:
    Jul 2013

    Posted 11 Mar 2014 Link to this post

    I already have the list of files in a custom template with guids.
    Again, the problem is that all the files on one select are associated with 1 input. So if i select 3 files, the widget will create 1 input for them, even if i have them displayed in the list as 3 separate files. So even if i assign the input an id, deleting it will delete all 3 files instead of deleting just 1! I need to know how i can delete just that 1 file by using it's id.
  7. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 11 Mar 2014 Link to this post

    Hi Cosmin,


    I was not aware of the exact scenario, so thank you for the providing the additional details.This could not achieved. The files list of a multiple input type="file" element is readonly, so individual files could not be removed.

    Regards,
    Dimiter Madjarov
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

  8. Cosmin
    Cosmin avatar
    7 posts
    Member since:
    Jul 2013

    Posted 11 Mar 2014 Link to this post

    Thank you for your reply, but this is unacceptable. So in the end, the sync upload control is only good for the most basic example. I have no control over the files or events that take place in this widget. This control is very old, shouldn't it reach some kind of maturity?
  9. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 11 Mar 2014 Link to this post

    Hi Cosmin,


    As stated in the previous post, this is the default behavior of the regular <input type='file' /> element with the multiple attribute set, which is used by the synchronous version of the Upload widget. Regarding the events, you could bind to the select and remove events, the rest are only fired in async mode.

    Regarding the last question, we do not consider that the Upload widget lifespan has come to an end. Nevertheless if you consider that we should implement some modifications, please feel free to post them as ideas in our Feedback portal.

    Regards,
    Dimiter Madjarov
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

Back to Top
UI for ASP.NET MVC is VS 2017 Ready