I am working in MVC, but I have put together a jsFiddle example at http://jsfiddle.net/UDX3L/21/
Thanks,
~Logan
1 Answer, 1 is accepted
I am not exactly sure what do you want to achieve, but you can use the save event of the grid (fired when the focus is moved outside of the cell being edited and before the cell is closed), here you can use the event object to prevent the change of the value if it does not match your criteria. Otherwise I would suggest the saveChanges event which is fired when the user press the save button.
You can take a look at the following API reference showing all the events, that the grid fires:
http://docs.kendoui.com/api/web/grid#events-cancel
Regards,
Kiril Nikolov
Telerik
thanks!
I am glad that you find my post helpful.
Please do not hesitate to contact us again, if you have any other questions.
Regards,
Kiril Nikolov
Telerik
The event appears to be working as needed, but now I need to be able to cancel the change and either:
1) revert it back to the original value (or a blank value) but with without any ui indication that it is dirty and will be saved.
2) leave the invalid value, but highlight the box (maybe set the background to red) and remove any ui indication that it is dirty and will be saved.
I have tried changing the value and setting dirty to false on both the e.model and the appropriate data row on e.sender._data with no success.
My current non working code is:
function
checkSave(e)
{
var
val = CheckGrade(e.model.GradingOption, e.values.FinalGrade, e.model.PreliminaryGrade);
if
(val.length > 0)
{
var
data = e.sender._data;
for
(
var
i = 0; i < data.length; i++)
{
var
row = data[i];
if
(row.id == e.model.id) {
row.dirty =
false
;
row.FinalGrade =
'?'
;
}
}
alert(val);
e.model.dirty =
false
;
e.model.FinalGrade =
'?'
;
return
true
;
}
return
false
;
}
Thanks for all of the help,
~Logan
Is this what you are looking for?
http://jsbin.com/evIYIHu/1/edit
With this the grid will not allow you to enter values bigger than 10.
Regards,
Kiril Nikolov
Telerik
Thanks,
~Logan
Is there a way to get the save event to fire when using a custom editor that does not have any data-bound inputs?
I'm also using batch/incell editing with version 2015.2.624.
I have multiple HTML inputs in a custom editor, so I can't use data-bind="" syntax because I need to manually set the model value using the correct input value when the user moves away from the edited cell. I can put a button/span that says "apply" or "save" that the user clicks in the cell and then in that Javascript function I can find the model object and field name programmatically, and save the model (this works fine). But I would like to do it when the user moves away from the cell, because having 1 column use something the user clicks on the save the cell looks odd when my other columns are not that way.
In a custom editor when no input uses the data-bind syntax, then the save event doesn't fire when moving away from the cell.
Hello Curt Rabon,
There is no way for the grid to fire the save event in your case. You can manually trigger it using the jQuery trigger() method. If you have any other questions, please open a separate support ticket and we will be happy to assist you.
Regards,Kiril Nikolov
Telerik
Internally you call CloseCell() to close the editor when focus is moved away. You already have the model object. All you would have to do is add a simple CellClose event for those of us that use complex custom editors. This would allow us to do model adjustments or "cleanup" when the cell is closing.
Would you please consider adding this event?
Hello Curt Rabon,
You can submit this as a feature request on UserVoice, so that it is considered for implementation in a future release.
Regards,Kiril Nikolov
Telerik