javascript - jQuery kendo 网格弹出编辑器不会将下拉值传递给 .net MVC 控制器?
问题描述
我正在尝试在 jquery kendo 网格弹出编辑器中编辑一行。但是当我单击更新按钮时,它不会将选定的下拉值提交给控制器,而它会毫无问题地提交其他属性。我尝试了很多例子,但没有一个效果很好。这是我的代码
var element = $("#grid").kendoGrid({
dataSource: {
type: "json",
transport: {
read: '/controller/GetEmployees',
update: {
url: "/controller/UpdateEmployee",
dataType: "json"
},
},
pageSize: 10,
serverPaging: true,
serverSorting: false,
schema: {
model: {
id: "EmployeeID",
fields: {
EmployeeID: { type: "number", editable: false },
EmployeeName: { type: "string", editable: true },
EmployeeStatus: { defaultValue: { ID: 1, Name: "Active" }, editable: true }
}
}
}
},
height: 500,
sortable: false,
pageable: false,
editable: "popup",
toolbar: ["create"],
columns: [
{
field: "EmployeeName",
title: "Employee Name",
width: "110px"
},
{
field: "EmployeeStatus",
title: "Status",
width: "110px",
editor: activeInactiveDropDownEditor,
template: "#=EmployeeStatus.Name#"
},
{
command: "edit",
width: "80px"
}
]
});
});
}
function activeInactiveDropDownEditor(container, options) {
$('<input required name="' + options.field + '" data-bind="ID"/>')
.appendTo(container)
.kendoDropDownList({
//autoBind: true,
dataTextField: "Name",
dataValueField: "ID",
dataSource: {
type: "json",
transport: {
read: "/controller/GetStatusList"
}
}
});
}
请问有人能在这里找到问题吗?
解决方案
最后我找到了解决方案。我刚刚使用 type 属性修改了更新请求,它现在运行良好。
update: {
type: 'post', // just added this and works well
url: "/controller/UpdateEmployee",
dataType: "json"
},
推荐阅读
- angular - 在另一个 angular-cli(7)(库)项目中覆盖自定义 scss 变量
- plot - 如何在自相关图中扩展 y 轴范围?
- javascript - 如何在依赖外部依赖的 vue.js 中对组件进行单元测试?
- javascript - 无法正确填充 state 中的属性以在 FlatList 的 renderItem 中使用它
- python - Python 在列表上使用 len 时,如何解决 < 的 TypeError?
- javascript - 如何删除 youtube 视频的名称?
- django - 在 django SignupForm 注册方法没有被覆盖
- python - 单击页面按钮后如何防止 Django 表单被重置
- javascript - 使用反应实现页脚不停留在底部
- python - 尝试使用条目小部件启用按钮