Kendo Hello Friends Have a grid with inline editing and to 3 drop-down lists. The display and fill the drop-down lists ok. Works but if I want to save changes, so do not get the desired data to the controller? The list the values I need are the IDs of the selected items from the drop! But come on, only the new text of the drop-down lists for the controller.
Here is my code and annexed the image on the controller
function
loadTable() {
var
dataSource =
new
kendo.data.DataSource({
transport: {
read: {
url:
"/Customer/LoadOperatingPictureTable"
,
dataType:
"json"
,
type:
"POST"
,
contentType:
"application/json; charset=utf-8"
,
data: {}
},
update: {
url:
"/Customer/UpdateAnimalValues"
,
dataType:
"json"
,
type:
"POST"
,
contentType:
"application/json; charset=utf-8"
},
parameterMap:
function
(data, operation) {
if
(operation !==
"read"
) {
return
JSON.stringify({ model: data });
}
}
},
autoSync:
false
,
schema: {
model: {
id:
"Id"
,
fields: {
Id: { editable:
false
, nullable:
true
},
Name: { editable:
false
},
AnimalCount: {
type:
"number"
,
validation: {
required: {
message:
"Das Feld darf nicht leer sein!"
}
}
},
Distributor: { editable:
true
},
Label: { editable:
true
},
Marketer: { editable:
true
}
}
}
},
error:
function
(e) {
alert(e.status +
' '
+ e.statusText);
}
});
$(
"div#operatingPictureTable"
).kendoGrid({
dataSource: dataSource,
scrollable:
true
,
sortable:
true
,
editable:
"inline"
,
columns: [
{
field:
"Name"
,
title:
"Tierkategorie"
},
{
field:
"AnimalCount"
,
title:
"Anzahl Tiere"
,
template:
'<div style="text-align: right">#= AnimalCount #</div>'
,
width: 80
},
{
field:
"Distributor"
,
title:
"Lieferant"
,
editor: onDrpDistributor
},
{
field:
"Label"
,
title:
"Label"
,
editor: onDrpLabel
},
{
field:
"Marketer"
,
title:
"Vermarkter"
,
editor: onDrpMarketer
},
{
command:
"edit"
,
titel:
" "
,
width: 110
}
],
});
function
onDrpDistributor(container, options) {
$(
'<input name="Distributors" data-bind="value:'
+ options.field +
'"/>'
)
.appendTo(container)
.kendoDropDownList({
dataTextField:
"Value"
,
dataValueField:
"Id"
,
autoBind:
false
,
dataSource:
new
kendo.data.DataSource({
transport: {
read: {
url:
"/Main/GetDistributors"
,
dataType:
"json"
},
schema: {
model:{
id:
"Id"
,
value:
"Value"
}
}
}
})
});
}
function
onDrpLabel(container, options) {
$(
'<input name="Distributors" data-bind="value:'
+ options.field +
'"/>'
)
.appendTo(container)
.kendoDropDownList({
dataTextField:
"Value"
,
dataValueField:
"Id"
,
autoBind:
false
,
dataSource: {
type:
"json"
,
transport: {
read:
"/Main/GetLabels"
}
}
});
}
function
onDrpMarketer(container, options) {
$(
'<input name="Distributors" data-bind="value:'
+ options.field +
'"/>'
)
.appendTo(container)
.kendoDropDownList({
dataTextField:
"Value"
,
dataValueField:
"Id"
,
autoBind:
false
,
dataSource: {
type:
"json"
,
transport: {
read:
"/Main/GetMarketers"
}
}
});
}
}