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

Adding an Id to selected items

7 Answers 247 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Cosmin
Top achievements
Rank 1
Cosmin asked on 07 Mar 2014, 12:59 PM
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?

7 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 11 Mar 2014, 09:09 AM
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.

0
Cosmin
Top achievements
Rank 1
answered on 11 Mar 2014, 09:14 AM
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.
0
Dimiter Madjarov
Telerik team
answered on 11 Mar 2014, 10:07 AM
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.

0
Cosmin
Top achievements
Rank 1
answered on 11 Mar 2014, 10:31 AM
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.
0
Dimiter Madjarov
Telerik team
answered on 11 Mar 2014, 11:15 AM
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.

0
Cosmin
Top achievements
Rank 1
answered on 11 Mar 2014, 01:03 PM
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?
0
Dimiter Madjarov
Telerik team
answered on 11 Mar 2014, 02:23 PM
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.

Tags
Upload
Asked by
Cosmin
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Cosmin
Top achievements
Rank 1
Share this question
or