kendoGrid内部可编辑的kendoGrid编辑弹出窗口无法正常工作

时间:2013-08-22 20:25:06

标签: jquery kendo-grid

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

我的问题如下: 拳头我有两个实体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。

1 个答案:

答案 0 :(得分: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:

相关问题