In a Grid, I try to edit a Product, that should have a unique Code.
In that case, I need the remote validation, to test, if the edited code would exist already in the database, different, from the edited product, of course.
For that, I need to send to the server the edited product Code, along with its Id.
In such cases, I would have an action like this, in the controller (documented here):
DTO:
[Remote(action: "VerifyCode", controller: "Products", AdditionalFields = nameof(ProductId))]
[Display(Name = "Product Code")]
public string Code { get; set; }
Controller:
[AcceptVerbs("GET", "POST")]
public IActionResult VerifyCode(string code, int id)
{
if (!_productService.VerifyCode(code, id))
{
return Json($"The code {code} is already taken by another product but shoud be unique, please change the code.");
}
return Json(true);
}
how to perform such validation when editing the Grid? Ideally inCell edit, but at least in Popup Mode....