[英]kendo ui dropdown not binding
我正在使用带有下拉列表的Kendo UI内联编辑。 在我的代码中,我从控制器函数中以JSON形式获取值。
下拉列表未绑定此JSON数据,它显示错误,因为无法识别e.slice。
$("#orderItems-grid").kendoGrid({
dataSource: datasource,
columns: [{
field: "Orderref",
title: "Order Ref",
editable: false
}, {
field: "ProductRef",
title: "Product Ref",
editable: false
}, {
field: "ProductNotes",
title: "Product Notes",
editable: false
}, {
field: "OrderStatusId",
title: "Order Status",
template: "#=OrderStatus#",
editor: function (container) {
var input = $('<input id="OrderStatusId" name="OrderStatusId">');
input.appendTo(container);
input.kendoDropDownList({
dataTextField: "Value",
dataValueField: "Key",
dataSource: {
transport: {
read: {
url: "/Order/GetOrderStatusListForDD",
type: "POST",
dataType:"json"
}
}
}
}).appendTo(container);
}
},
{ command: { name: "edit", text: "Edit Status" } }],
editable: "inline"
});
我的JSON结果是
{“ 16”:“分配到拣配队列”,“ 2”:“等待批准”,“ 10”:“等待下单”,“ 9”:“等待库存”,“ 6”:“已取消”, “ 14”:“已取消并重置产品”,“ 7”:“已拒绝”,“ 8”:“已停产”,“ 11”:“已停产并找到替代品”,“ 15”:“已开票”,“ 1”: “已收到订单”,“ 3”:“已发送给供应商的订单”,“ 5”:“已发货”,“ 4”:“存储区”}
您有两次.appendTo(container)。 尝试这个:
editor: function (container, options) {
$('<input data-bind="value:' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
dataTextField: "Value",
dataValueField: "Key",
dataSource: {
transport: {
read: {
url: "/Order/GetOrderStatusListForDD",
type: "POST",
dataType: "json"
}
}
}
});
}
更新:在您的GetOrderStatusListForDD()操作中,结果必须实现IEnumerable,然后返回Json(result)将返回正确的JSON
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.