I have a grid, one of the columns is a dropdown which comes from another datasource. When the grid goes into edit mode I select the dropdown. However if I select the first item in the dropdown it's value is never retrurned. If I select any other value it's fine, also if I select another value and then the first one it is also ok.
My code is:
$("#memberGrid").kendoGrid({
dataSource: dataSource,
toolbar: ["create"],
columns: [
{ field: "LOGIN_NAME", title: "User Name", editor: userDropDownEditor, template: "#=LOGIN_NAME#" },
{ command: ["edit", "destroy"], title: " ", width: "172px" }
],
editable: "inline",
});
My template function is:
function userDropDownEditor(container, options) {
$('<input required data-text-field="LOGIN_NAME" data-value-field="LOGIN_NAME" data-bind="value:' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: true,
dataSource: {
transport: {
read: '@Url.Action("GetAvailableUsers", "Role")'
}
}
});
}
My Data source is:
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: '@Url.Action("GetUsersObjectInRole", "Role")' + "?roleName=" + roleName
},
create: {
url: '@Url.Action("AddUserToGroup", "Role")',
contentType: "application/json",
type: "POST"
},
parameterMap: function (data, operation) {
if (operation != "read") {
return JSON.stringify(data);
} else {
return JSON.stringify(data); //return stringified options to the server
}
}
},
schema: {
model: {
id: "LOGIN_NAME",
fields: {
LOGIN_NAME: { type: "string" },
GROUP_ID: {type: "number" }
}
}
}
});
If I check the value of the field in parameterMap it is always empty. This is really weird, I can't see how it can be a code issue. Thanks.
My code is:
$("#memberGrid").kendoGrid({
dataSource: dataSource,
toolbar: ["create"],
columns: [
{ field: "LOGIN_NAME", title: "User Name", editor: userDropDownEditor, template: "#=LOGIN_NAME#" },
{ command: ["edit", "destroy"], title: " ", width: "172px" }
],
editable: "inline",
});
My template function is:
function userDropDownEditor(container, options) {
$('<input required data-text-field="LOGIN_NAME" data-value-field="LOGIN_NAME" data-bind="value:' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: true,
dataSource: {
transport: {
read: '@Url.Action("GetAvailableUsers", "Role")'
}
}
});
}
My Data source is:
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: '@Url.Action("GetUsersObjectInRole", "Role")' + "?roleName=" + roleName
},
create: {
url: '@Url.Action("AddUserToGroup", "Role")',
contentType: "application/json",
type: "POST"
},
parameterMap: function (data, operation) {
if (operation != "read") {
return JSON.stringify(data);
} else {
return JSON.stringify(data); //return stringified options to the server
}
}
},
schema: {
model: {
id: "LOGIN_NAME",
fields: {
LOGIN_NAME: { type: "string" },
GROUP_ID: {type: "number" }
}
}
}
});
If I check the value of the field in parameterMap it is always empty. This is really weird, I can't see how it can be a code issue. Thanks.