Remove a file from async upload list.

1 Answer 10 Views
Upload
Jed
Top achievements
Rank 1
Iron
Jed asked on 16 Nov 2021, 08:28 PM | edited on 16 Nov 2021, 08:33 PM

I have a kendo upload on one of my forms. This upload button has the following async, multiselect, autoUpload = false, batch = true. The problem I am running into is if the user selects 5 files, but meant to only select 4, they click the remove icon for that row.

I am having issues removing that file from the file portion of the upload control. If I select 5 and then remove them all, the upload is still acting as if all 5 are there. kendoUpload.getFiles() is always showing me every file they selected.

 

Just be clear, I am trying to remove a file from memory before the user fully uploads them. The process is that they select the files, the files populate a grid, and then once the user is ready they click an 'upload' button that will fire off the server call. Prior to them clicking upload everything is client side.

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 19 Nov 2021, 11:04 AM

Hi Jed,

I tested the described behavior in the Dojo linked here. However, the getFiles method is always returning the correct count of files, even after removing a file. Could you please take a look at the example and let me know if I am missing something?

Looking forward to your reply.

Regards,
Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Jed
Top achievements
Rank 1
Iron
commented on 19 Nov 2021, 03:16 PM

Yes I can see the Dojo is functioning correctly. Our situation is slightly different in that we are using a separate remove button because of other actions that will need to take place at the same time. In the function that is called when they click the remove button I have been trying to get the removeFile method to remove the selected file, but doesn't seem to ever remove anything. The removeFileByUid is not working either.  Below is the code for our remove function

 

self.deleteFile = function (data) {
        var grid = $("#" + self.MultipleUploadDetailsGridId).data("kendoGrid");
        var dataitem = this.dataItem($(data.currentTarget).closest("tr"));

        grid.dataSource.remove(dataitem);
        self.MultipleUploadDetails.remove(function (uploadDetail) {
            return uploadDetail.FileName == dataitem.FileName;
        });
        self.UploadDocuments.remove(function (uploadDoc) {
            var nameNoExtension = uploadDoc.name.substring(0, uploadDoc.name.length - uploadDoc.extension.length);
            return nameNoExtension == dataitem.FileName;
        });

        var upload = $("#" + self.MultipleUploadButtonId).data("kendoUpload");
        //Remove method here

        grid.dataSource.sync();
    };

Jed
Top achievements
Rank 1
Iron
commented on 19 Nov 2021, 07:11 PM | edited

After testing I wanted to add some details.

We want the ability to let the users select multiple files at once, but to be able to remove a single file from the group. All files have to get sent in a single controller call (so batch has to be true).

I am noticing that when I set batch to false, I can successfully delete a single file, but that introduces the problem of all the files not being sent in a single call.

Hopefully that makes sense.

 

edit: It is also worth noting that we are using a separate grid to show the selected files. This is due to the fact that each file has the possibility of having other information associated with them.

Neli
Telerik team
commented on 24 Nov 2021, 11:10 AM

Hi Jed,

Currently uploading multiple files and removing a single one is not supported when the batch option is enabled.

I would suggest you log the idea in our official Feedback Portal. This way the other users could vote for the request. The most popular requests are considered for future implementation. 

- https://feedback.telerik.com/kendo-jquery-ui

Regards,

Neli

 

Tags
Upload
Asked by
Jed
Top achievements
Rank 1
Iron
Answers by
Neli
Telerik team
Share this question
or