Remote validation of fields in Grid Popup

1 Answer 218 Views
Editor Grid
serge
Top achievements
Rank 2
Bronze
Iron
Iron
serge asked on 09 May 2021, 03:36 PM

Could we have an example of remote validation when Popup editing of a grid object ?

I added the [Remote] attribute to the DTO object. Added the Controller's check method, that receives always null as parameter, where should receive the modified string param. Please see for details the following question. I also get in the request playload the correct parameter, when the client sends to the server. But on the server side - always null.

1 Answer, 1 is accepted

Sort by
0
Mihaela
Telerik team
answered on 12 May 2021, 06:41 PM

Hi Serge,

Attached you can review a demo project with a grid in "Popup" edit mode and remote validation for the field "ShipName". The action method "IsShipName_Available" is added in the GridController and it checks if the added "ShipName" already exists. 

In addition, I would suggest reviewing the article below that illustrates how to validate with the "AddModelError" method:

https://docs.telerik.com/aspnet-core/html-helpers/data-management/grid/editing/popup#handling-modelstate-errors

Would you please give a try of the demo project and let me know if you have any questions or concerns?

Best, Mihaela 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/.

serge
Top achievements
Rank 2
Bronze
Iron
Iron
commented on 13 May 2021, 10:38 AM | edited

your project has the same problem as mine, when you Edit the ShipName1 of obj1 it surely finds the ShipName1 in the repository, because the obj1 itself contains that name, so says is invalid. The test should be made against the ID as well, so, ID should be passed as AdditionalField.
Mihaela
Telerik team
commented on 14 May 2021, 06:53 AM | edited

Hi Serge, 

Thank you for the clarification.

I have revised the demo project (the attachment in the answer above is updated) where both properties are sent to the Action method that validates the record.

Would you please review it and let me know if you have any questions or concerns?

 

Best,MihaelaProgress Telerik

serge
Top achievements
Rank 2
Bronze
Iron
Iron
commented on 15 May 2021, 09:50 PM | edited

the application you gave me is obsolete, I didn't arrive to launch it. I use .NET 5, the sample is .NET 2.1... errors when launcing it... anyway, as I see the code, the problem now is that id==0 (new shipment) it does not check the code at all...
Mihaela
Telerik team
commented on 19 May 2021, 02:55 PM

I have updated the attached demo (in the answer above) to the latest version of the Telerik for UI ASP.NET Core (2021.2.511) and .NET 5.0. 

In addition, I have updated the input for the id in the popup window to be read-only. Basically, it will never be equal to "0", since it is assigned in the Create Action method.

Would you please review the revised demo and let me know if it works out for you?

Tags
Editor Grid
Asked by
serge
Top achievements
Rank 2
Bronze
Iron
Iron
Answers by
Mihaela
Telerik team
Share this question
or