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

Help with Upload with List View (MVC 3)

2 Answers 171 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 01 Aug 2012, 04:44 PM
  1. I need help with Kendo Upload. This is my problem:
  2. I have a partial view which displays a ListView of Company object. In the Edit EditorTemplate, I have a Kendo Upload control that enables the user to upload company logo. This works fine
  3. However, I need to grab the Id of the company being edited so that I can save the logo image by replacing the File Name with the Id of the company. This is what I have not being able to do.
  4. I tried using the .Events attribute, however, once I add that attribute to the upload control, the upload button turns into a regular HTML button, thus it only selects the picture, but is not able to upload it asynchronously. I have read of other solutions such as putting the upload within a form element, however since this upload is performed in ListView edit mode, I don’t see that as a good option.
  5. All I need is to be able to grab the company Id from the company Id editor field. I want to do this in the Save method of the upload control. Something like how it’s done in standard MVC controller, like: string companyName = Request.Form["CompanyName"]; How can I achieve this? 
Thank you.

2 Answers, 1 is accepted

Sort by
0
Andreas
Top achievements
Rank 1
answered on 01 Nov 2012, 11:29 AM
Hi
I have the same problem and get function onError not defined as soon as I place it inside a partial view. On regular views it works, have you found a solution.
0
Daniel
Telerik team
answered on 06 Nov 2012, 02:52 PM
Hello,

You can send additional data to the server by using the upload event like described in this documentation topic and the model data can be found by using the data-uid  attribute on the listview item e.g.

function upload(e){
    var listViewItem = this.element.closest("[data-uid]"); 
    var listView =  listViewItem.closest("[data-role=listview]").data("kendoListView");
    var item = listView.dataSource.getByUid(listViewItem.data("uid"));
    e.data = {
        id: item.ID
    };
}

The most likely reason for an error thrown for missing handler when used in the editor template is that the handler is added after the upload widget and it is not defined yet. If this is not causing the problem I will the code you are using or a runnable sample to check the exact setup. Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Upload
Asked by
Mark
Top achievements
Rank 1
Answers by
Andreas
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or