2013-08-22 56 views
0

这是我的第一篇文章,所以对我很好。kendoGrid里面的可编辑kendoGrid编辑弹出不能正常工作

我的问题是以下几点: 拳头我有两个实体关联和地址(关联有很多地址)。

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

回答

0

试试这个,

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: