I am trying provide a custom type in the schema of the datasoure object of kendogrid. Here is my code sample.
//type: "servicePath.SLF.solutionEngine.Model.EntityRef",
How I can specify this type while defining a schema. My "EntityRef" has two fields
id and Name which are of type strings.
Anybody have idea who I can do that.
Thanks
oThis.productsDataSource = new kendo.data.DataSource
({
pageSize: 10,
transport: {
read: {
url: crudServiceBaseUrl + "GetAll",
dataType: "json"
},
update: {
url: crudServiceBaseUrl + "Post",
contentType: "application/json",
type: "POST",
dataType: "json"
},
destroy: {
url: crudServiceBaseUrl + "Delete",
contentType: "application/json",
type: "DELETE",
dataType: "json"
},
create: {
url: crudServiceBaseUrl + "New",
contentType: "application/json",
type: "POST",
dataType: "json"
},
parameterMap: function (data, type) {
if (type !== "read" && data.models) {
return kendo.stringify(data.models[0]);
}
}
},
schema: {
model: {
id: "Id",
fields: {
Id: { editable: false, nullable: true },
Name: { validation: { required: true } },
ResourceCostBandId: {
//type: "servicePath.SLF.solutionEngine.Model.EntityRef",
fields: {
Id: { editable: false },
Name: { editable: false }
},
validation: { required: true }
}
}
}
},
batch: true
});
How I can specify this type while defining a schema. My "EntityRef" has two fields
id and Name which are of type strings.
var grid = this.element.kendoGrid({
columns: [
{ field: "Name", title: "Name", width: 200, validation: { required: true } },
{
// Following binding not working but when I change it to following
//field: "ResourceCostBandId"
// It works but then it set the value on the ResourceCostBandId. I want it to be set on ResourceCostBandId.Id
field: "ResourceCostBandId.Id", title: "Cost Band",
width: 200, validation: { required: true },
template: "#= ResourceCostBandId.Name #",
editor: function (container, options) {
$('<
input
required
data-text-field
=
"Name"
data-value-field
=
"Id"
data-bind
=
"value:' + options.field + '"
/>')
.appendTo(container)
.kendoDropDownList({
dataTextField: "Name",
dataValueField: "Id",
dataSource: oThis.controller.$scope.ResourceCostBands,
index: 0
});
}
},
{ command: ["edit", "destroy"], title: " ", width: "172px" }
],
toolbar: ["create"],
pageable: { "pageSize": 5, "refresh": true, "pageSizes": true },
autoBind: true,
dataSource: oThis.productsDataSource,
resizable: true,
editable: 'inline',
selectable: true,
});
Anybody have idea who I can do that.
Thanks