By design, the Remote Validation mechanism is used for form validation. However, the grid's data cells could be validated by sending their values to the validation controller via an AJAX call.
In order to send additional fields along with the field that needs to be validated, you could add them as properties of the "data" object. The example below illustrates how to send the values of the fields "Code" and "Id" to the Action method "IsCode_Available" in the Grid Controller (the grid is in "InCell" edit mode):
<script>
$(document).ready(function () {
$.extend(true, kendo.ui.validator, {
rules: {
remote: function (input) {
if (input.is("[name=Code]") && input.val()) {
//var grid = $("#grid").data("kendoGrid"); //an instance of the gridvar dataItem = grid.dataItem($(input).closest('tr')); //get the dataItemvarrecordID = dataItem.Id; //get the value of field "Id"var recordCode = input.val(); //get the value of the validated field (i.e "Code")
$.ajax({
url: '@Url.Action("IsCode_Available", "Grid")',
type: "POST",
async: false,
data: { "Code": recordCode, "id": recordID},
success: function (data) {...},
error: function () {...}
});
returntrue
}
returntrue
}
},
messages: {
remote: function (input) {...}
}
});
});
</script>
//Model
[Remote("IsCode_Available", "Grid", AdditionalFields = nameof(Id))] public string Code {