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

Custom data in template

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

13 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 11 Mar 2014, 11:02 AM
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!
0
Gensys Development
Top achievements
Rank 1
answered on 12 Mar 2014, 10:59 AM
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.





0
Dimiter Madjarov
Telerik team
answered on 14 Mar 2014, 09:12 AM
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!
 
0
Gensys Development
Top achievements
Rank 1
answered on 21 Mar 2014, 12:31 PM
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?
0
Dimiter Madjarov
Telerik team
answered on 24 Mar 2014, 03:06 PM
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!
 
0
Gensys Development
Top achievements
Rank 1
answered on 26 Mar 2014, 01:32 PM
Hi,

Yes a guid to identify each file would be great.
0
Dimiter Madjarov
Telerik team
answered on 26 Mar 2014, 03:00 PM
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!
 
0
Dimiter Madjarov
Telerik team
answered on 03 Apr 2014, 03:21 PM
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!
 
0
Gensys Development
Top achievements
Rank 1
answered on 07 Apr 2014, 02:59 PM
Hi,

That is great, thank you!
0
Karthik
Top achievements
Rank 1
answered on 17 Apr 2015, 07:34 PM

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

 

0
Dimiter Madjarov
Telerik team
answered on 20 Apr 2015, 08:41 AM

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!
 
0
Karthik
Top achievements
Rank 1
answered on 20 Apr 2015, 01:42 PM

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

 

 

 

 

0
Dimiter Madjarov
Telerik team
answered on 21 Apr 2015, 08:05 AM

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!
 
Tags
Upload
Asked by
Gensys Development
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Gensys Development
Top achievements
Rank 1
Karthik
Top achievements
Rank 1
Share this question
or