e.preventDefault() 阻止剑道'read'事件,但不适用于在剑道弹出窗口编辑器中更新按键的'create'


 transport: {
            parameterMap: function (data, operation) {
                if (operation !== "read") {
                    return JSON.stringify(data);
                } else {
                    return (data);
                }
            },
            read: {
                url: function () {
                    return moduleServiceRoot;
                },
                type: "GET",
                dataType: "json",
                async: true
            },
            create: {
                url: function (rec) {
                    return moduleServiceRoot; 
                },
                type: "POST",
                contentType: 'application/json; charset=utf-8',
                dataType: "json",
                async: true
            },
            complete: function (e) {
                $("#grid").data("kendoGrid").dataSource.read();
                async: true
            },
        },
        requestStart: function (e) {
            console.log('request started');
            if (e.type == 'create' & validInput == false) {
                console.log('request started');
                e.preventDefault();
            }
        }

在上面的代码中,有效输入始终为假。 如果我注释掉 if 语句 Kendo 网格读取操作被阻止(网格不显示任何数据),但如果我取消注释它,当我在 Kendo 弹出窗口编辑器中点击更新时,它不适用于剑道创建。

create: function (options) {
                if (validInput) {
                    $.ajax({
                        url: moduleServiceRoot,
                        dataType: "json",
                        type: "POST",
                        contentType: 'application/json; charset=utf-8',
                        async: true,
                        data: JSON.stringify(options.data),
                        success: function (result) {            // notify the data source that the request succeeded,
                            options.success(result);
                        },
                        error: function (result) {              // notify the data source that the request failed
                            options.error(result);
                        }
                    });
                }
            }

它工作正常

最新更新