Reputation: 1817
I have done some clientside validation.
parameterMap: function(options, operation) {
if (operation !== "read") {
var valid = customValidation(options);
console.log(valid);
if (valid) {
return JSON.stringify({ discountPromotionViewModel: options });
}
}
},
And if the customValidation method returns false i don't want the grid to post the data. Now it posts an empty model so it still reaches my controller. How do i prevent it from even posting the data?
Upvotes: 0
Views: 996
Reputation: 2596
Do your validation inside Grid's event save
, then if it's invalid result prevent it with e.preventDefault
function. It will prevent POST request to server.
$("#grid").kendoGrid({
// some grid configuration
save: function(e) {
var model = e.model,
valid = customValidation(model);
if(!valid) e.preventDefault();
}
});
Upvotes: 1