I have a grid where the data model has a complex object, for example:
var item = {
ActivityType: { Id: 1, Name: "Cold Call" }
};
When I create an editor with a select item, like this:
editor: {
type: 'select',
valueIndx: "Id",
labelIndx: "Name"
options: [ { Id: 1, Name: "Cold Call" }, { Id: 2, Name: "Email"}, { Id: 3, Name: "Visit" } ]
};
I cannot get the value to save to the complex object in the data item. Here is a jsfiddle demonstrating what I mean--The Activity column will not update, but the description will because it is not complex.
I attempted to add a getData handler like this:
getData: function (ui) {
var val = ui.$cell.find("select").val();
var txt = ui.$cell.find("select").find("option:selected").text();
return { Id: val, Name: txt };
}
but it does not work (and throws an error).
Can anyone help?
Thanks in advance.