【问题标题】:editable kendoGrid inside kendoGrid Edit Popup not working correctlykendoGrid Edit Popup 内的可编辑 kendoGrid 无法正常工作
【发布时间】:2013-08-23 17:13:35
【问题描述】:

这是我的第一篇文章,所以请善待我。

我的问题如下: 拳头我有两个实体 Associated 和 Address(一个关联有很多地址)。

网页有一个可编辑的 kendoGrid 列出关联(数据源包含所有关联的每个及其地址列表),当我单击编辑按钮时,会出现一个弹出窗口,其中包含数据和一个带有地址列表的可编辑 kendoGrid。我点击编辑按钮,出现编辑地址弹出窗口,但更新按钮不起作用,取消按钮删除该行。

以下是我的代码

数据源

associatedDS = 
new kendo.data.DataSource({        
 data: Data,
 schema: {
  model: {
   id: "AsociatedID",
   fields: {
    Associated: { type: "string", editable: false, nullable: true },
    Addresses: { type: "object", validation: { required: true } }                        
   }
  }  
 }
});

网格关联

var Associated = 
$("#kgrd_Associated").kendoGrid({
 columns: [
 { field: "AsociatedID", title: "Direccion", width: "100px", },
 { field: "Associated", title: "Direccion", width: "100px", },
 { field: "Addresses", title: "Addresses", width: "350px", editor:addressGridEditor, template: "#= Addresses.length #" },
 { command: ["edit", "destroy"], title: " ", width: "150px"  }
],
dataSource: associatedDS,
editable: "popup",
height: 400,
pageable: true,
scrollable: true,
sortable: true,
selectable: "row",
}).data("kendoGrid"); 
});

网格地址

function editor:addressGridEditor(container, options) {  
 var repgrid = $('<div id="kgrd_Address" data-bind="source:' + options.field + '"></div>')
 .appendTo(container)
 .kendoGrid( {
  columns: [                    
   { field: "Address",   title: "Address", width: "150px"   },
   { command: ["edit", "destroy"],   title: "&nbsp;", width: "150px"  }
  ],
  editable: "popup",
  scrollable: true,
  selectable: "row",
  autoBind: true                
  }).data("kendoGrid");
}

绑定工作正常,但 kgrd_Address 的数据源未正确生成,因为缺少架构(需要更新)和 _pristineData(需要取消)。

我不知道我是否遗漏了什么,或者是否有解决方法。考虑到我在弹出窗口中可能有多个 kendoGrid,例如 idk、kgrd_contacts。

【问题讨论】:

    标签: jquery kendo-grid


    【解决方案1】:

    试试这个,

      function addressGridEditor(container, options) {  
         var repgrid = $('<div id="kgrd_Address" data-bind="source:' + options.field + '"></div>')
         .appendTo(container)
         .kendoGrid( {
          columns: [                    
           { field: "Address",   title: "Address", width: "150px"   },
           { command: ["edit", "destroy"],   title: "&nbsp;", width: "150px"  }
          ],
          editable: "popup",
          scrollable: true,
          selectable: "row",
          autoBind: true                
          }).data("kendoGrid");
        }
    

    我认为你必须从函数中删除 editor:

    【讨论】:

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