When trying to filter the ProcessType column in the example below, I receive a 400 error. If I change the field to ProcessTypeID from ProcessType the filter works but than the add/edit options do not work correctly. I tried injecting a custom filter and received the same result. I followed the api documentation to the GitHub Odata 4 with WebAPI controller example, downloaded and ran locally and get the same result. Can someone point in the right direction on this?
<
div
id
=
"grid"
></
div
>
<
script
>
$(function() {
$("#grid").kendoGrid({
dataSource: {
type: "odata-v4",
transport: {
read: {
url: "/odata/Processes",
data: {
$expand: "ProcessType"
}
},
update: {
url: function (data) {
return "/odata/Processes(" + data.ProcessID + ")";
}
},
create: {
url: "/odata/Processes?$expand=ProcessType"
}
},
schema: {
model: {
id: "ProcessID",
fields: {
ProcessID: { type: "number" },
Name: { type: "string" },
Description: { type: "string" },
ProcessTypeID: { type: "number" },
Enabled: { type: "boolean", defaultValue: true },
DDLFile: { type: "string" },
Type: { type: "string" },
Method: { type: "string" },
Parameter: { type: "string" },
ProcessType: { defaultValue: { ProcessTypeID: 1, Name: "Import" } }
}
}
},
requestEnd: function(e) {
if (e.type == "create") {
// Make a read request to expand Category. By default the OData controller doesn't expand on create.
this.read();
}
},
change: function(e) {
console.log(e.sender);
},
pageSize: 10,
serverFiltering: true,
serverPaging: true,
serverSorting: true
},
height: "485px",
toolbar: ["create"],
sortable: {
mode: "multiple",
allowUnsort: true
},
filterable: {
mode: "row"
},
resizable: true,
scrollable: true,
pageable: {
pageSizes: [10, 25, 50],
buttonCount: 5
},
columns: [
{ command: "edit", width: 200 },
{ field: "Name", width: 400 },
{ field: "Description", width: 400 },
{ field: "ProcessType", width: 300, title: "Process Type", template: "#: ProcessType ? ProcessType.Name : '' #", editor: processTypeEditor },
{ field: "Enabled", width: 170 },
{ field: "DLLFile", width: 400 },
{ field: "Type", width: 400 },
{ field: "Method", width: 400 },
{ field: "Parameter", width: 400 }
],
editable: "inline",
edit: function (e) {
if (!e.model.isNew()) {
var processType = $(e.container.find('input[data-role="dropdownlist"]')).data("kendoDropDownList");
processType.enable(false);
e.container.find('input[name=Name]').attr('disabled', 'disabled').addClass('k-state-disabled');
}
},
save: function (e) {
e.model.set("ProcessTypeID", e.model.ProcessType.ProcessTypeID);
}
});
});
function processTypeEditor(container, options) {
console.log(options);
$('<
input
required
data-text-field
=
"Name"
data-value-field
=
"ProcessTypeID"
data-bind
=
"value:' + options.field + '"
/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataSource: {
type: "odata-v4",
transport: {
read: {
url: "/odata/ProcessTypes"
}
}
}
});
}
</
script
>