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

Upload server error display in widget

4 Answers 365 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
Dan asked on 25 Feb 2020, 08:35 AM
The application has a restriction for the name of the file to be maximum of 40 characters. Since this validation is done on the server is there a way to display the server upload error just like the file extension/ max file size.

4 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 27 Feb 2020, 08:31 AM

Hello, Dan,

I'm afraid that you cannot directly plug in the server error in the client validation of the Upload component. However, what you can do is - handle the error event of the upload component and display the custom error:

https://docs.telerik.com/kendo-ui/api/javascript/ui/upload/events/error

The event will be triggered if you throw a new exception on the server and pass back the text of the error for example. Then, in the event handling, you can read the error message and display it in a preferable manner. Keep in mind that the red validation will paint the Upload component, but you would need to manually append the error message (or alert such).

Hope this would help.

Regards,
Nencho
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
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 27 Feb 2020, 08:41 AM

Hi Nencho,

I already handle the error and got the message my problem is displaying it like the extension/max file size in the widget (with the colors and icons and the html structure) I hoped that the widget would provide a functionality so that if I do this not to have backward compatibility issues when updating the newer versions like before.

Thanks anyway.

0
Ivan Danchev
Telerik team
answered on 02 Mar 2020, 09:11 AM

Hi Dan,

With regard to the widget's functionality when it comes to showing custom messages, it allows you to use a template. In it you can nest arbitrary Html and show/hide some of the elements conditionally.

Here's a dojo example, that shows how you can have a template and still display validation messages by showing/hiding the span with class "validation-message", depending on the extension of the selected file: https://dojo.telerik.com/aGiLudOl

Consider using a similar approach in your scenario - show/hide the element that contains the message with jQuery, when the error event fires.

Regards,
Ivan Danchev
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
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 02 Mar 2020, 09:18 AM

Hi Ivan

Thank you for the suggesting template. I did not think of using it and it seems to be a valid solution.

Tags
Upload
Asked by
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Nencho
Telerik team
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
Ivan Danchev
Telerik team
Share this question
or