javascript - jQuery kendo 网格弹出编辑器不将下拉值传递给 .net MVC Controller ?

标签 javascript jquery kendo-ui popup kendo-grid

我正在尝试在 jquery kendo 网格弹出编辑器中编辑一行。但是,当我单击更新按钮时,它不会将选定的下拉值提交到 Controller ,而它会毫无问题地提交其他属性。我尝试了很多例子,但没有一个效果很好。 这是我的代码

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"
                }
            }
        });
}

有人能找到这里的错误吗?

最佳答案

终于找到解决办法了。我刚刚用类型属性修改了更新请求,现在效果很好。

                update: {
                    type: 'post', // just added this and works well
                    url: "/controller/UpdateEmployee",
                    dataType: "json"
                },

关于javascript - jQuery kendo 网格弹出编辑器不将下拉值传递给 .net MVC Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60611705/

相关文章:

javascript - 在 tinyMce 中触发 keyPressEvent

javascript - 使用 $.getJSON 获取 404

javascript - 合并并返回唯一数组问题

javascript - Kendo Grid 在 Change 事件上获取行和列索引

jquery - 从 Kendo 下拉列表值选择中获取后代

javascript - 如何查看 url 是否仅限移动设备

javascript - JSP Javascript,更新java对象值

javascript - 通过 Javascript 的 MS Word 对象模型 : Mail Merge

jquery - 同时使用 jQuery .find() 和多个条件?

javascript - 在不调用 read() 的情况下设置剑道数据源