Reputation: 7442
I am using Kendo Grid with AngularJS. I am having real trouble getting change event to not fire based on some condition. I am trying the following approach but doing so has no effect.
change: function (e){
if(somecodition)
e.preventDefault();
}
how can I stop user from changing row (based on some condition)
ended up implementing the following solution. thanks for the help from dimodi
Solution
var lastRow;
function onSelection(e){
var row = e.sender.element.find(".k-state-selected");
if(/*some condition*/) {
row.removeClass("k-state-selected");
e.sender.select(lastRow);
}
else {
lastRow= row;
}
}
Upvotes: 1
Views: 1371
Reputation: 4139
The change
event cannot be prevented, however, you can save the current selection in each event firing, and if needed, restore the previous selection with the Grid's select
method. Beware not to enter an endless loop when using the select
methid in a change
handler.
http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#methods-select
Upvotes: 2