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

Kendo Upload - Pass in other parameter of Model to custom template

3 Answers 814 Views
Upload
This is a migrated thread and some comments may be shown as answers.
lucerias
Top achievements
Rank 1
lucerias asked on 27 Jan 2016, 06:40 PM

Hi,

I have fileObjects and it has properties (name, extension, size, filepath). I understand name, extension and size are the reserved keywords that can be used in template code. However, i need the filepath (additional parameter) to be passed and used in template code.

So that when user click on the hyperlink, it will call the download function with two parameter (path and name). File path is mandatory because each file is stored in respective unique id (folder name) folder.

<% List<FileModel> files = ViewBag.files; %>
var fileObjects = <%: Html.Raw(Json.Encode(files)) %>
 
$("#upload-file").kendoUpload({
    async: {
        saveUrl: "<%: Url.Action("UploadFile", ViewBag.Controller, new { topicId = Model.Id }) %>",
        removeUrl: "<%: Url.Action("RemoveFile", ViewBag.Controller, new { topicId = Model.Id }) %>",
        autoUpload: true
    },
    template:
        "<span class='k-progress' style='width: 100%;'></span>" +
        "<span class='k-icon k-i-doc'></span>" +
        "<span class='k-filename' title='#=name#'><a href='\\#' onclick='downloadFile(\"#=name#\")'>#=name#</a></span>" +
        "<strong class='k-upload-status'>" +
            "<button type='button' class='k-button k-button-bare k-upload-action'>" +
                "<span class='k-icon k-i-close k-delete' title='Remove'></span>" +
            "</button>" +
        "</strong>",
    files: fileObjects,
    success: onSuccess,
    error: onError,
    upload: onUpload
});

 

Thanks.

Regards,
Yap Hui Hong

3 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 29 Jan 2016, 03:43 PM

Hello,

Indeed at the moment only name, size and extension are passed as template data for the files. A possible resolution for the current case would be to add an element in the template for displaying the path and manually populate it after the widget is rendered. Here is a sample implementation that demonstrates the mentioned approach.

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
Kevin F
Top achievements
Rank 1
answered on 27 May 2016, 04:43 PM
It would be very helpful to have the UID passed in to the template as well.  I'm trying to implement a template where the user can click on a file name inside the upload control to view it.  Since the files in this case are stored in the database, having the UID available would be very convenient!
0
Dimiter Madjarov
Telerik team
answered on 30 May 2016, 08:15 AM

Hello Kevin,

Thank you for the feedback. We will consider it for future versions. At the moment you could access the uid in the click handler you are implementing, by accessing the current file list item and it's data-uid attribute.

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
lucerias
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Kevin F
Top achievements
Rank 1
Share this question
or