Kendo ui e、 preventDefault()防止剑道';阅读';事件,但不适用于';创建';在剑道弹出编辑器中更新按键

Kendo ui e、 preventDefault()防止剑道';阅读';事件,但不适用于';创建';在剑道弹出编辑器中更新按键,kendo-ui,kendo-grid,Kendo Ui,Kendo Grid,在上面的代码中,validInput始终为false。如果我注释掉if语句,那么kendo grid read操作将被阻止(网格不显示任何数据),但如果我取消注释它,当我在kendo弹出编辑器中点击update时,它将不适用于kendo create transport: { parameterMap: function (data, operation) { if (operation !== "read") {

在上面的代码中,validInput始终为false。如果我注释掉if语句,那么kendo grid read操作将被阻止(网格不显示任何数据),但如果我取消注释它,当我在kendo弹出编辑器中点击update时,它将不适用于kendo 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();
            }
        }

它工作正常

我不确定e.preventDefault是否是中止XML HTTP请求的正确方法。您是否尝试过使用abort方法?您是对的,KendoUI检查
read
是否键入返回值,但不检查其他事件。但是同意@ThilakRao,在什么情况下你想取消更新?也许在别的地方比较容易,而且有较少的方面effects@OnaBai如果用户试图添加现有记录,我想取消创建事件。我实际上是在用数据库中的值验证用户输入并显示kendoAlert,一切正常,但无法取消创建事件,因此在DB中添加了重复值。@Thilak Rao不,我没有尝试过。
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);
                        }
                    });
                }
            }