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

Validation Message from Remote Validation

1 Answer 1004 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Curt
Top achievements
Rank 1
Curt asked on 03 Mar 2021, 05:08 PM

 

Hello,

I've done quite a bit of searching and I'm going in loops between hitting other products (mvc, Kendo, etc.) or coming back to the same example (link below). 

 

 

This is what I'd like to be able to do;   Upon user clicking the update/save button I'd like to attempt to save the bound model data, validate it on the server side, (key being server side) and if there are any errors, return to the client and indicate the error within the grid popup (I know how to prevent the popup from going away based upon other examples).   The notification example is very poor (the link below).  It shows the error in its own popup window, and if the user hits cancel on the Grid Popup, the notification popup remains until they close it.  It's not a very elegant solution, and I'm not aware of any other site/web application that behaves this way.

One prime example is the user attempts to save a new item, but names the item the same accidentally as one already in the database causing a key violation.  It would be nice to display "Item with name provided already exists", right above text entry field "Name" on the popup.  Gets right to the point, does not require user to look elsewhere for the issue and/or acknowledge an additional popup.   

Any suggestions for how to accomplish such a repetitive task (common server side validation errors)?   We'd prefer NOT providing/creating a custom form/component for each and every set of items (objects) that we need to edit from within a grid/gird popup. 

On a side note;  It seems this would be a pretty common scenario.   We should never trust the clients validation, so all validation should be done again on the server anyway.   If the server is a REST api, the same errors could and should occur on the server and returned to the client that would normally get trapped on a blazor client. It would be very nice if your Blazor popup (as one example) implementation (and other standard edits) could elegantly handle/display the servers side error messages.  Or am I missing an implementation somewhere?

Thanks in advance,

Curt

 

Current "Notification" example:

https://github.com/telerik/blazor-ui/tree/master/grid/remote-validation

 

 

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 04 Mar 2021, 07:56 AM

Hi Curt,

To begin with some more details on the current situation.

Creating a custom edit form is the general way to handle custom validation (such as calling remote endpoints). The Telerik Form component can make it easy to generate the form and you could plug your own custom remote validator there too with just one line of markup. In under 10 lines you can generate a form for dozens of fields. You can then even extract this to a reusable component.

Moreover, having that in your own code will let you create and handle server responses as you see fit, so you can even convert them to validation messages to pass on to a custom validation message store in your own form. This is serious flexibility that is only possible through application-speific code.

Exposing such a thing for configuration inside the grid would mean exposing literally all the current editing functionality as a template, which is equivalent to writing your own custom edit form in terms for your development effort, but it will require more tags, more specific syntax and for you to know where in the grid to put that, as opposed to having the full freedom of Blazor. It will also add complexity to the grid and take away time we could otherwise use to implement other things that can actually save you code and time.

On to the future features that could help you.

At the moment we are also working on adding an EditContext to grid rows that are in edit mode so that the other grid edit modes will have validation. This should allow you to implement a custom validator for remote validation and put it in the editor template of the special field.

As for the current example - when an Alert window becomes available, it would be a better replacement for the notification. If you choose to go with creating a custom editing form you won't need such "external" error display.

Regards,
Marin Bratanov
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/.

Sagar
Top achievements
Rank 1
commented on 24 Jul 2023, 10:06 AM

Hi Marin Bratanov, do you think its possible to achieve the same remote server side validation for dynamically
generated Telerik text input items inside Form?
I want to show the field validation error below the field that is violated and not in a general validation summary box.

Thanks.

Nadezhda Tacheva
Telerik team
commented on 27 Jul 2023, 08:11 AM

Hi Sagar,

It is generally possible to use remote validation for a Form. You can refer to this sample app that includes a From with automatically generated fields: https://github.com/telerik/blazor-ui/tree/master/form/remote-validation.

If you do not want to summarize the validation errors, you may not declare a Notification component and ValidationSummary inside the <FormValidation>. Thus, you will have the error messages appearing only under the corresponding fields.

I hope this helps you move forward with your application.

Tags
Grid
Asked by
Curt
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or