Hi, Andrei,
The Kendo UI Grid for MVC initializes its validator as soon as the grid is put into edit mode and runs its rules on cell close.
To achieve the custom validation, regardless of the edit modes, we have one and the same approach - extend the Kendo UI Validator with the custom rule, much like you are doing in the edit event. We have a runnable demo with sample code that you can use at:
https://demos.telerik.com/aspnet-mvc/grid/editing-custom-validation
The custom required rule in your case would look something like this. Here is a runnable example for your reference:
https://dojo.telerik.com/@bubblemaster/oWIwAMUP/2
<script type="text/javascript">
(function ($, kendo) {
$.extend(true, kendo.ui.validator, {
rules: {
customrequired: function (input, params) {
if (input.is("#column_LongNameId") && !input.val()) {
input.attr("data-customrequired-msg", "Name is required");
var grid = input.closest(".k-grid").data("kendoGrid");
var dataItem = grid.dataItem($(".k-grid-edit-row"));
return dataItem.code === "A" || dataItem.code === "B";
}
return true;
}
},
messages: {
customrequired: function (input) {
return input.attr("data-val-customrequired");
}
}
});
})(jQuery, kendo);
</script>
Give this a try and let us know in case you need further assistance.
Kind Regards,
Alex Hajigeorgieva
Progress Telerik