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

Get list of selected attachments from kendoUpload control

4 Answers 473 Views
Grid
This is a migrated thread and some comments may be shown as answers.
nick001
Top achievements
Rank 1
nick001 asked on 07 May 2015, 05:02 AM

I have a grid in which column allows users to attach 1 or more files for a given row.  The users can add attachments one at a time.

After they have completed adding files, i would like to read the list of files from the kendoUpload control and upload them along with other data in the grid in one shot.

 The code below however always returns only one file even if there is more than one that the user added.  Any ideas why this is?

 

var fileData = new FormData();
//prefix files with assumptionCode to map them to appropriate record in controller
$.each($("input[type=file]"), function (i, obj) {
    debugger;
    var id = $(this).closest('form').attr('id');
    $.each(obj.files, function (j, file) {
        fileId = id + '_' + file.name
        fileData.append(fileId, file);
    })
});
 

For the the column that contains the kendoUpload controls, i am using a custom template which returns the following:

   frm = "<form method='post' action='#' enctype = 'multipart/form-data' id='" + data.Code + "' >"
            + "<input class='attachments' tabindex='-1' name='files[]' type='file' "
            + "id='" + data.Code + "' /></form>"
 
    return frm

 Any idea why this is happening and how to resolve

 

 

4 Answers, 1 is accepted

Sort by
0
nick001
Top achievements
Rank 1
answered on 07 May 2015, 05:05 AM

For got to mention that in the grid's onDataBoundChange event, i do the following:

 

$(".attachments").kendoUpload({
    multiple: false,
});

0
T. Tsonev
Telerik team
answered on 11 May 2015, 07:36 AM

Hello nick001,

The behavior you see is a result of setting multiple: false on the upload. In this mode it will allow only one file to be selected at any given time.

The upload doesn't support a mode where it allows selecting multiple files, but one at a time. This can be retro-fitted, but the code is a bit messy.

I hope this helps.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
nick001
Top achievements
Rank 1
answered on 11 May 2015, 05:40 PM

Sorry, I had multiple set to true before and the behavior was same.  So for now we're only allowing a single attachments since it doesn't seem to be working  for multiple attachments...

In short, even if multiple is set to true, the same behavior is observed

0
T. Tsonev
Telerik team
answered on 13 May 2015, 10:45 AM

Hello,

The code snippet you pasted earlier seems to work fine. Can you please share a more detailed demo, or modify mine, to demonstrate the problem?

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
nick001
Top achievements
Rank 1
Answers by
nick001
Top achievements
Rank 1
T. Tsonev
Telerik team
Share this question
or