Hello, Its been week and still no luck on dropdown and finally I'm throwing up my towel. I hope you can help me on this.
Please help! thanks!
var lastNameData =[{"lastName":"White","lastNameID":0},{"lastName":"Great","lastNameID":1}];
var lastNameDataSource = new kendo.data.DataSource({
data: lastNameData,
schema: {
model: {
id: "lastNameID"
}
}
});
function lastNameDropDownEditor(container, options) {
$('<
input
data-bind
=
"value:' + options.field + '"
/>')
.appendTo(container)
.kendoComboBox({
autoBind: false,
dataTextField: "lastName",
dataValueField: "lastName",
dataSource: lastNameDataSource
});
}
var blankData;
$(document).ready(function () {
var dataSource = new kendo.data.DataSource({
parameterMap: function(options, operation) {
//alert(operation);
if (operation !== "read" && options.models) {
return {models: kendo.stringify(options.models)};
}
},
transport: {
read: {
dataType: "json",
type: "POST",
data: {"SQLCMD":"SELECT * FROM gridTest","Table":["firstName","nickName","lastName"],"PrimaryKey":"peopleID"}
},
update: {
type: "POST"
},
destroy: {
type: "POST"
},
create: {
type: "POST",
data: {
req: ["firstName","nickName"] }
}
},
// determines if changes will be send to the server individually or as batch
batch: false,
//...
pageSize: 30,
data: blankData,
autoSync: true,
schema: {
model: {
id: "peopleID",
fields:
{"peopleID":{"editable":false,"nullable":true},"firstName":{"type":"string","validation":{"required":true},"nullable":false,"defaultValue":""},"nickName":{"type":"string","validation":{"required":true},"nullable":false,"defaultValue":""},"lastName":"lastName"} }
, parse: function (data) {
// alert(data);
return data;
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 340,
toolbar: ["create"],
columns:
[{"field":"firstName","title":"First name"},{"field":"nickName","title":"Nick Name"},{"field":"lastName","width":"150px","editor":"lastNameDropDownEditor"},{"command":"destroy","title":" ","width":"110px"}] ,
editable: true
});
});
Please help! thanks!