移动应用中的kendo网格更新不会发送模型

时间:2015-06-09 18:36:59

标签: kendo-mobile

我正在尝试从移动应用中的网格更新一行,但该模型未发送到服务器。

我使用的是剑道2015.1.429

我的观点是:

<div data-role="view" data-init="initGrid" data-stretch="true">
    <div data-role="header">
    </div>
    <div id="grid">
    </div>
</div>
    <script type="text/javascript">
    function initGrid() {

        var dataSource3 = new kendo.data.DataSource({
            transport: {
                read: {
                    url:  "@Url.Action("GetAll")",
                    dataType: "json"
                },
                update: {
                    url: "@Url.Action("Update")",
                    dataType: "json"
                },
                destroy: {
                    url: "@Url.Action("Destroy")",
                    dataType: "json"
                },
                create: {
                    url: "@Url.Action("Create")",
                    dataType: "json"
                },
                parameterMap: function (options, operation) {
                    if (operation !== "read" && options.models) {
                        return { models: kendo.stringify(options.models) };
                    }
                }
            },
            batch: false,
            schema: {
                data:"Data",
                model: {
                    id: "ID",
                    fields: {
                        ID: { type: "number", editable: false, nullable: false },
                        Name: { type: "string" }

                    }
                }
            }
        });

        $("#grid").kendoGrid({
            dataSource:dataSource3,
            pageable: true,
            mobile: "tablet",
            height: kendo.support.mobileOS.wp ? "24em" : 430,
            resizable: true,
            editable: {
                mode: "popup"

            },
            toolbar: ["create"],
             columns: [
                        { field: "ID", title: "ID", width: 200},
                        { field: "Name", title: "Name"},       
                        { command: ["edit", "destroy"] } 
                      ]
        });
  }
</script>

控制器中的Update方法是:

 public ActionResult Update([DataSourceRequest] DataSourceRequest request, Model viewModel)
        {

            return Json(new[] { viewModel }.ToDataSourceResult(request, ModelState));

        }

&lt; - EDITED 2 - &gt; 我在Fiddler看到没有数据发送到我的方法Update。

我忘了做什么?我做错了什么?

1 个答案:

答案 0 :(得分:0)

如果我删除parameterMap

  parameterMap: function (options, operation) {
                    if (operation !== "read" && options.models) {
                        return { models: kendo.stringify(options.models) };
                    }
                }

它很棒。

谢谢!