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

Async Upload Success Handler fires only Once for Multiple Files

6 Answers 643 Views
Upload
This is a migrated thread and some comments may be shown as answers.
jwize
Top achievements
Rank 1
jwize asked on 14 Dec 2013, 11:15 AM
I have an Kendo upload control set to upload multiple files. The files upload as expected. The problem that I am facing is that I have to update a grid based on the files that were just uploaded. The problem is that the success handler is only fired once upon completion of the uploads. These are handled quickly as they are asynchronous. So, basically when the the success handler is reached I call  mygrid.dataSource.read(). This results in the datasource reading only the first record from the server since the others are not finished processing. There is no easy way to sort this problem out. The complete handler is fired immediately after the success handler so that doesn't help either. Seems like a bug to me but let me know if I am wrong. The success handler should fire once for each file and the complete handler should be fired only after all the files are uploaded successfully or not(am I wrong?).

6 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 14 Dec 2013, 05:52 PM
Hi Jaime,

Indeed the success event is fired once for each file and the complete event is fired after all files are uploaded. This behavior could be observed in our events demo.

If the problem is still persisting, please send me a small runnable isolated example, which demonstrates the issue, so I could assist you further.

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
Massimo
Top achievements
Rank 1
answered on 18 Jun 2019, 04:25 PM

Hello Dimiter, the event Complete is fired every file when chunk upload is enabled.

Are there other ways to know when all files has been uploaded?

0
Martin
Telerik team
answered on 20 Jun 2019, 01:26 PM
Hello Massimo,

I have prepared a Dojo example which demonstrates a possible workaround. In the complete event, you can get the count of the items that are in the upload file list. You can also get the items which have already been uploaded (or have failed uploading): 
complete: function(e){         
  var items = e.sender.wrapper.find('.k-file').length;
  var uploadedItems = e.sender.wrapper.find('.k-file-success, .k-file-invalid').length;

You can then compare if their count is equal. If it is, then all the files are loaded.

Don't hesitate to ask if you have questions regarding the suggested approach.

Regards,
Martin
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Massimo
Top achievements
Rank 1
answered on 20 Jun 2019, 02:47 PM
Thank you for your help
0
Joon-Sae
Top achievements
Rank 1
answered on 07 Apr 2020, 10:59 PM

 

In the sample, if you use it exactly as copied, success is called after each success, however if you don't use the progress event the success is only called once at the end.  If this is working as intended, this is confusing.

0
Joon-Sae
Top achievements
Rank 1
answered on 07 Apr 2020, 11:41 PM
Ignore my post, my debugger was collapsing the same success messages in the console :$
Tags
Upload
Asked by
jwize
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Massimo
Top achievements
Rank 1
Martin
Telerik team
Joon-Sae
Top achievements
Rank 1
Share this question
or