【问题标题】:Kendo Grid PopUp Editor Will Not Close剑道网格弹出编辑器不会关闭
【发布时间】:2013-07-06 10:15:34
【问题描述】:

我有一个基本的网格 可编辑:“弹出”

我有一个带有“编辑”的命令列。我正在使用定义了读取、更新、创建和销毁的远程数据源。网格正常工作,当我单击 Edit 时,会出现弹出窗口,其中包含我的所有字段。如果我在字段中输入一些更改并单击更新,数据将被提交(我可以看到 ajax 帖子)但弹出窗口没有关闭。

我的更新按钮有这些类“k-button k-button-icontext k-grid-update”。 我的弹出窗口有这些类“k-widget k-window”。

取消按钮关闭窗口,右上角的 X 也关闭窗口。

有什么想法吗?

我的数据源代码:

var dataSource = new kendo.data.DataSource({
    transport: {
      read: {
        url: "myReadURL",
        dataType: "json"
      },
      update: {
        url: "myUpdateURL",
        dataType: "json"
      },
      create: {
        url: "myCreateURL",
        dataType: "json"
      },
      destroy: {
        url: "myDestroyURL",
        dataType: "json"
      }
    },
    schema: {
        data: "data",
        total: function(response){return $(response.data).length;},
        model: {
          id: "id",
            fields: {
                id: { type: "number", editable: false },
                location: { type: "string" },
                username: { type: "string" },
                host: { type: "string" },
                model: { type: "string" },
                newhost: { type: "string" },
                newserial: { type: "string" },
                newassettag: { type: "string" },
                complete: { type: "boolean" }
            }
        }
    },
    pageSize: 10
});

我的网格初始化代码:

$("#grid").kendoGrid({
  dataSource: dataSource,
          height: 430,
          filterable: true,
          sortable: true,
          resizable: true,
          scrollable: true,
          pageable: {
              refresh: true,
              pageSizes: [10,20,100]
          },
          columns: [{
                  hidden: true,
                  field:"id"

              },{
                command: "edit",
                  title: " ",
                  width: 90

              },{
                  field: "location",
                  title: "Location",
                  width: 120,
                  filterable: {ui: cityFilter}

              },{
                  field: "username",
                  title: "Username",
                  width: 120

              },{
                  field: "host",
                  title: "Host",
                  width: 180
              },{
                  field: "model",
                  title: "Model",
                  width: 180

              },{
                  field: "newhost",
                  title: "New Host",
                  width: 180

              },{
                  field: "newserial",
                  title: "New Serial",
                  width: 180

              },{
                  field: "newassettag",
                  title: "New Asset",
                  width: 180

              },{
                  field: "complete",
                  title: "Complete",
                  template: "<input type='checkbox' # if(complete){ # checked #} #/>",
                  width: 70

              }
          ],
          editable: "popup"

});

我的html:

<div id="example" class="k-content">

    <div id="grid" style="height: 380px"></div>

</div>

【问题讨论】:

  • 您介意编辑您的帖子并包含用于初始化网格和数据源的代码吗?
  • 更新帖子以包含数据源和网格初始化代码。我确实在架构中定义了一个 id。我正在使用 Kendo UI v2013.1.319 和 jQuery 1.9.1。我也尝试过使用弹出窗口的模板。除了关闭之外,它在所有方面都有效。

标签: grid kendo-ui


【解决方案1】:

您的服务需要返回一个有效的 JSON 文档,即使它是空的。如果您的服务没有响应任何内容或返回无法解析为 JSON 的内容,则它不会关闭弹出窗口。

例如:创建一个名为 myUpdateURL 的文件,其中仅包含:

{}

它应该可以工作。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-05-04
相关资源
最近更新 更多