现在,我正在学习使用kendoui开发一个Web应用程序,当我尝试使用自定义弹出窗口kendoWindow而不是kendo内置编辑窗口来处理网格数据时,我不知道如何将请求发送到远程服务,因此我尝试在this page的官方api文档中找到答案,但是发生了一个新问题,显示为以下代码:

<script>
    var dataSource = new kendo.data.DataSource({
        transport: {
            read  : function (options) {
                /* implementation omitted for brevity */
            },
            update: function (options) {
                // make JSONP request to http://demos.kendoui.com/service/products/update

                $.ajax({
                    url     : "http://demos.kendoui.com/service/products/update",
                    dataType: "jsonp", // "jsonp" is required for cross-domain requests; use "json" for same-domain requests
                    // send the updated data items as the "models" service parameter encoded in JSON
                    data    : {
                        models: kendo.stringify(options.data.models)
                    },
                    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);
                    }
                });
            }
        },
        batch    : true,
        schema   : {
            model: { id: "ProductID" }
        }
    });

    dataSource.fetch(function () {
        var product = dataSource.at(0);
        product.set("UnitPrice", 20);
        dataSource.sync(); makes request to http://demos.kendoui.com/service/products/update
    });
</script>

这是一个示例,用于说明如何将update指定为向远程服务发出HTTP请求的函数

我的问题是传递给读取和更新功能的参数“选项”是什么。
我发现的唯一线索是transport.parametermap函数的参数,但是我不确定它们之间是否存在某些关系,因此希望有人为我解释一下

最佳答案

options参数是您已经发现的。
KendoUI让我们为它的数据源类的数据访问方法指定一个函数而不是一些配置。

如果指定函数,那么kendoUI怎么会知道何时完成数据加载?不能。
因此,此选项变量将传递给您的函数(实际上,它可以具有每个名称,例如dfhajkfhd),您可以调用该名称以使kendoUI知道您的进度。
为此,您可以调用成功错误方法。

您从kendo-docs复制的评论完全是这样说的。

还是您有不同的疑问?

10-06 13:20
查看更多