kendoGrid编辑弹出菜单中的可编辑kendoGrid无法正常工作



这是我的第一篇文章,所以对我好一点。

我的问题如下:首先我有两个实体Associated和Address(一个Associated有很多地址)。

该网页有一个可编辑的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。

试试这个,

  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:

最新更新