I am working with the good example of Editing custom editor under the MVC examples.
It shows how to build a dropdownlist for use when editing a cell in a grid.
I have to create a new post in the grid and I add the following to the file; Editing_Custom.cshtml:
.Create(create => create.Action("EditingCustom_Create", "Grid"))
.ToolBar(toolBar => { toolBar.Save(); toolBar.Create(); })
And I already get an error here before I come to do the coding in the .cs-file.
When debugging with firebug, I get an error from javascript that says: ReferenceError: EnrollTypes is not defined.
EnrollTypes is the class that is used for making the dropdownlist.
Could someone please give me a hint on what I have to do when creating a post in a grid with relational data?
I saw in some forum that Foregin key will sove this problem, but in my case there is no key column which can be named as foreign key. I just want to have a dropdown in grid column and it should also appear when I click on Add New Item button.
Regards,
Nitin
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 340,
toolbar: ["create"],
columns:
[{"field":"firstName","title":"First name"},{"field":"nickName","title":"Nick Name","template":"#= kendo.toString(nickName,'MM/dd/yyyy') #"},{"field":"lastName","width":"150px","editor":lastNameEditor},
{"command":"destroy","title":" ","width":"110px"}] ,
editable: true
});
});
var dataSource = new kendo.data.DataSource({
parameterMap: function(options, operation) {
//alert(operation);
return kendo.stringify(options);
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","lastName"] }
}
},
// 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":"date","validation":{"required":true},"nullable":false,"parse":function(value) { return kendo.toString(value) }},
"lastName":{"type":"string","validation":"required":true},"nullable":false}} }
, parse: function (data) {
// alert(data);
return data;
}
}
});