Is handling the set event of the data-model supposed to prevent the grid's save event from firing?? It does for me. See here: http://jsfiddle.net/hvzw7/
Commenting out the set event will allow the save event to fire.
Also, the set event's parameters appear to be 2 separate parameters: the field and the field's value, but the documentation states one parameter with 2 properties (e.field and e.value).
11 Answers, 1 is accepted
The Grid save event will not fire because when handling the set function of the model the record is not marked as dirty and the change event is not raised. You should either use the default function or perform the same actions in order for the values to be saved.
Kind regards,Daniel
the Telerik team
What about the documentation discrepancy I mentioned??
Thanks.
When specifying the set option to the model, you will override the function instead of binding to the "set" event. In order to bind to the event of the observable object you should use code after loading data or in the Grid edit event in this case. For convenience I updated the jsFiddle sample to show the second approach.
Regards,Daniel
the Telerik team
Thanks for posting a workaround, but you still haven't answered my question about the documentation discrepancy. Please answer. See my first post for details.
I am not sure if I understand correctly the problem with the documentation. The set event of the observable object receives a single parameter which has fields field and value. The set method accepts two parameters the field name and the value. Could you specify where in the documentation it is stated that the set event has two parameters?
Regards,Daniel
the Telerik team
http://docs.kendoui.com/api/framework/observableobject#set-event
Under the "Event Data" section of the "Set Event", you see e.field, e.value ...but the event actually receives 2 different arguments, not 1 argument with 2 properties. Please see here for proof:
http://jsfiddle.net/hvzw7/
In this jsFiddle, change the product name cell value to something like "cat", and the set event fires, where you can see the 2 different arguments (not one argument "e" with 2 properties).
As in one of my previous replies I can say, that when specifying the set option to the model like in the jsFiddle sample:
model: {
set:
function
(field, fieldValue) {
log.append(
'<br />(model set) '
+ field +
': '
+ fieldValue);
}
Daniel
the Telerik team
kendo.data.ObservableObject.fn.set.call(this, name, value);
correct? Being able to override the set method is better than handling your own change event.
set:
function
(name, value) {
if
(name ===
"stuff"
) { value =
"foo bar"
; }
kendo.data.ObservableObject.fn.set.call(
this
, name, value);
}
We haven't recommended this approach but it is a possible solution.
Regards,
Daniel
Telerik