18.Nov.15

Milan Nankov

Milan Nankov

Code Bites: Resetting Kendo Upload When Using AngularJS

Kendo Upload is a component that lets you easily select and upload files. If you are reusing the component for multiple file upload operations you will notice that currently there is no good way to reset the component to its initial state and clear the list of the previously selected/uploaded files.

kendo-upload-file-list
One way to deal with this is to recreate the widget every time you need it. Of course, you cannot do this by simply adding html code using jQuery - you have to make sure that the Kendo directives are executed. We do this by introducing a function called resetUpload() that will remove the old Kendo Upload instance and will create a brand new one using the $compile service of AngularJS.

What we have here is a simple form in a popup window. Whenever the form is shown a brand new Kendo Upload instance is created so that no artifacts from previous file selections are shown.

Hope that this little trick will be helpful to some of you out there.
 

Need consulting on this topic?

Yes No