Upload server error display in widget

5 posts, 0 answers
  1. Dan
    Dan avatar
    200 posts
    Member since:
    Nov 2017

    Posted 25 Feb 2020 Link to this post

    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.
  2. Nencho
    Admin
    Nencho avatar
    1890 posts

    Posted 27 Feb 2020 Link to this post

    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.
  3. Dan
    Dan avatar
    200 posts
    Member since:
    Nov 2017

    Posted 27 Feb 2020 in reply to Nencho Link to this post

    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.

  4. Ivan Danchev
    Admin
    Ivan Danchev avatar
    2189 posts

    Posted 02 Mar 2020 Link to this post

    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.
  5. Dan
    Dan avatar
    200 posts
    Member since:
    Nov 2017

    Posted 02 Mar 2020 in reply to Ivan Danchev Link to this post

    Hi Ivan

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

Back to Top