2016-12-15 152 views
0

这个问题创造了一个排的扩展,现有一个:How to copy paste an entire row with in the same grid in Kendo UI Jquery剑道网 - 编辑为重复一个

我能在点击按钮添加重复行,但我现在面临的问题是我还需要编辑重复行而不是原始行。每当我对细胞点击编辑我得到这个错误: kendo.all.js:4515遗漏的类型错误:i.wrap不是一个函数(...)

我能够编辑原始行,但不能够编辑重复的行。我在这里错过了什么吗?

回答

0

假设您要添加重复的行完全按照链接的提问/回答描述...

当我使电网编辑我没有得到这个错误:真。您将需要提供一个代码示例,显示您的设置和错误。

现在,我已经说出了,我已经采取了相关的答案,并从它做出了一个Dojo,使网格可编辑,并成功地编辑了重复的行。

http://dojo.telerik.com/@Stephen/EHeFU

的微小变化必须作出让编辑为没有他们正常工作,编辑重复的DataItem也会使更改原始DataItem的,因为它们具有相同的标识,除非你做些什么它,即:

$("#duplicate").on("click", function() { 
    var items = []; 
    $(":checked", grid.tbody).each(function(idx, elem) { 
     var row = $(elem).closest("tr"); 
     // Must duplicate the raw data only using toJSON(), otherwise the duplicated item will have the same identifier(uid) as the original. 
     var item = grid.dataItem(row).toJSON(); 
     items.push(item); 
    }); 
    for (var i = 0; i < items.length; i++) { 
     // You must also clear the model's id field otherwise the copy may not be treated as a new item. 
     items[i].ProductID = 0; 
     grid.dataSource.add(items[i]); 
    } 
}); 
+0

@Stephen:谢谢!显然我错过了上面提到的JSON部分的“必须”部分。奇迹般有效! –