【发布时间】:2015-04-24 10:57:33
【问题描述】:
这是我的网格:
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: {
url: '/Discount/Get',
dataType: "jsonp",
type: "POST"
},
update: {
url: '/Discount/Update',
dataType: "jsonp",
type: "POST"
},
destroy: {
url: '/Discount/Delete',
dataType: "jsonp",
type: "POST"
},
create: {
url: '/Discount/Add',
dataType: "jsonp",
type: "POST"
},
parameterMap: function (options, operation) {
console.log(operation);
console.log(options);
if (operation == "update") {
return { discountId: options.models.DiscountId, discountValue: options.models.DiscountValue }
}
if (operation == "create") {
return JSON.stringify({ discountValue: options.models.DiscountValue, topItemName: options.models.TopItemName });
}
if (operation == "destroy") {
return { discountId: options.models.DiscountId }
}
}
},
schema: {
model: {
id: "DiscountId",
fields: {
DiscountId: { type: "number" },
TopItemName: { type: "string" },
DiscountValue: { type: "number" }
}
}
}
},
toolbar: ["create", "save", "cancel"],
height: 400,
sortable: true,
pageable: true,
columns: [
{
field: "TopItemName",
filterable: true
},
{
field: "DiscountValue",
format: "{0:p0}",
editor: function (container, options) {
$("<input name='DiscountValue'>")
.appendTo(container)
.kendoNumericTextBox(
{
min: 0,
max: 1.0,
step: 0.01
});
}
}],
editable: true
});
在网格中,我有一个自定义编辑器,可以将文本框设置为百分比。
在我的 console.log 中,当我进行创建调用并得到了这个
Object {DiscountId: 0, TopItemName: "asdasd", DiscountValue: "0.05"}
所以DiscountValue 有一个值。但我仍然得到错误:
Uncaught TypeError: Cannot read property 'DiscountValue' of undefined
DiscountValue 是浮点值吗?
【问题讨论】:
标签: javascript post telerik kendo-grid