首页 文章

Kendo Grid PopUp编辑器无法关闭

提问于
浏览
4

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

我有一个带有"edit"的命令列 . 我使用远程数据源定义了read,update,create和destroy . 网格有效,当我单击 Edit 时,会出现弹出窗口,其中包含我的所有字段 . 如果我在字段中输入一些更改并单击 Update ,则会提交数据(我可以看到ajax帖子),但弹出窗口不会关闭 .

我的 Update 按钮有这些类"k-button k-button-icontext k-grid-update" . 我的弹出窗口有这些类"k-widget k-window" .

Cancel 按钮关闭窗口,右上角的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>

1 回答

  • 6

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

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

    {}
    

    它应该工作 .

相关问题