Hi,
Maybe I missed something obvious but how can I know and handle change when user edit a cell ?
I have read that fire fires before the grid item is changed and change event in dataSource do not seem to be called.
For information I'm not using remote data but local.
Thanks
Yvan
Maybe I missed something obvious but how can I know and handle change when user edit a cell ?
I have read that fire fires before the grid item is changed and change event in dataSource do not seem to be called.
For information I'm not using remote data but local.
var
data =
new
Array();
data.push({Id:
'id'
});
var
grid = $(
"#grid"
).kendoGrid({
dataSource: {
data: data,
schema: {
model: {
fields: { Id: { type:
"string"
, validation: { required:
true
} },}
}
},
change:
function
() {console.log(
'dataSource change'
);},
},
editable:
true
,
toolbar: [
"create"
,
"save"
,
"cancel"
],
columns: [{field:
"Id"
,},],
save:
function
(data) {
console.log(
'grid save'
);
for
(i
in
data)
console.log(i +
' = '
+ data.i);
},
}).data(
"kendoGrid"
);
Thanks
Yvan
7 Answers, 1 is accepted
0

Yvan
Top achievements
Rank 1
answered on 12 Dec 2011, 11:00 PM
Ok, now I'm able to retrieve the edited value :
But i'm still sweating to access all other fields of my row. Any idea?
save:
function
(data) {
console.log(
'new value for MyField = '
+ data.values.MyField);
},
But i'm still sweating to access all other fields of my row. Any idea?
0
Hello Yvan,
Regards,
Rosen
the Telerik team
Besides the values extracted from the cell, the edited Model instance will be provided as argument of Save event. You may use it to get values of other fields of the item.
save:
function
(e) {
var
myOtherFieldValue = e.model.get(
"myOtherField"
);
}
Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0

Yvan
Top achievements
Rank 1
answered on 14 Dec 2011, 08:57 PM
Hello Rosen,
Thanks for your help. Indeed e.mode.get("myField") works.
But I'm facing another issue. Considering the following code:
Grid is displayed correctly. But when I try to edit the first row, data from the second appears in field.
I tested with more than two rows and it's always the data of the last which are use.
Is it a misfunction or a misusage of my part?
Best regards,
Yvan
Thanks for your help. Indeed e.mode.get("myField") works.
But I'm facing another issue. Considering the following code:
var
data =
new
Array();
data.push({FirstName:
'John'
, LastName:
'Doe'
,});
data.push({FirstName:
'Chuck'
, LastName:
'Norris'
,});
var
grid = $(
"#grid"
).kendoGrid({
dataSource: {
data: data,
schema: {
model: {
fields: {
FirstName: { type:
"string"
},
LastName: { type:
"string"
},
}
}
},
},
editable:
true
,
columns: [
{ field:
"FirstName"
, },
{ field:
"LastName"
, },
],
}).data(
"kendoGrid"
);
Grid is displayed correctly. But when I try to edit the first row, data from the second appears in field.
I tested with more than two rows and it's always the data of the last which are use.
Is it a misfunction or a misusage of my part?
Best regards,
Yvan
0
Hi Yvan,
Best wishes,
Rosen
the Telerik team
The behavior you have described is caused by the fact that there is no id specified in the model declaration:
schema: {
id:
"MyIDField"
,
model: {
fields: {
FirstName: {
type:
"string"
},
LastName: {
type:
"string"
},
}
}
}
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0

Yvan
Top achievements
Rank 1
answered on 15 Dec 2011, 09:08 PM
Hi Rosen,
Id has fix my issue. But just for the record, id should be placed into model:
I'm very excited about new grid features coming in March.
Thanks a lot for your help.
Best regards
Id has fix my issue. But just for the record, id should be placed into model:
schema: {
model: {
id:
"MyIDField"
,
fields: {
//...
I'm very excited about new grid features coming in March.
Thanks a lot for your help.
Best regards
0

Yvan
Top achievements
Rank 1
answered on 28 Dec 2011, 10:42 PM
Hi,
In documentation it's written that save fires before the item grid is changed which is not really useful for my purpose.
Is there a possibility of handling change after this one was done?
Best regards
In documentation it's written that save fires before the item grid is changed which is not really useful for my purpose.
Is there a possibility of handling change after this one was done?
Best regards
0
Accepted
Hello Yvan,
There isn't such event, but you can handle the change of the model which will be triggered if the save event is not prevented.
Regards,
Nikolay Rusev
the Telerik team
There isn't such event, but you can handle the change of the model which will be triggered if the save event is not prevented.
Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!