gpt4 book ai didi

javascript - 无法使用 customdropdown 读取未定义的 kendo ui js 网格的属性 'data'

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:43:14 25 4
gpt4 key购买 nike

这是我的js代码:

$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
transport: {
read: {
url: '/Discount/Get',
dataType: "json",
},
update: {
url: '/Discount/Update',
dataType: "json",
type: "POST"
},
destroy: {
url: '/Discount/Delete',
dataType: "json",
type: "POST"
},
create: {
url: '/Discount/Add',
dataType: "json",
type: "POST"
},
parameterMap: function (options, operation) {
if (operation == "update") {
return JSON.stringify(options);
}
if (operation == "create") {
return options;
}
if (operation == "destroy") {
return JSON.stringify(options);
}
}
},
schema: {
model: {
id: "Id",
fields: {
Id: { type: "number" },
TopItemName: { type: "string" },
DiscountValue: { type: "number" },
}
}
}
},
toolbar: ["create", "save", "cancel"],
height: 400,
pageable: true,
columns: [
{
field: "TopItemName",
editor: topItemDropDown,
template: "#=TopItemName#"
},
{
field: "DiscountValue",
format: "{0:p0}",
editor: function (container, options) {
$("<input name='DiscountValue'>")
.appendTo(container)
.kendoNumericTextBox(
{
min: 0,
max: 1.00,
step: 0.01
});
}
}],
editable: true
});

function topItemDropDown(container, options) {
$('<input required data-text-field="TopItemName" data-value-field="TopItemName" data-bind="value:' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataSource: {
transport: {
url: '/Discount/GetTopItemName',
dataType: "jsonp",
type: "POST",
contentType: "application/json"
}
}
});
}
});

下拉菜单已正确实现。所以有一个下拉菜单,但当我按下它时,它应该发布到我的 Controller 方法并获取值,但我收到此错误:

Cannot read property 'data' of undefined

这是我的操作方法:

       public ActionResult GetTopItemName([DataSourceRequest] DataSourceRequest request)
{
var customer = custAdapter.GetCustomersByCustomerId(SessionStore.CustomerId);
return Json(customer, JsonRequestBehavior.AllowGet);
}

什么是数据?为什么它是未定义的?

最佳答案

我忘记了数据源的读取函数所以它应该是这样的:

     transport:{
read: {
url: '/Discount/GetTopItemName',
dataType: "json",
type: "POST",
contentType: "application/json"
},
}

关于javascript - 无法使用 customdropdown 读取未定义的 kendo ui js 网格的属性 'data',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29891754/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com