jqGrid:组合sortableRows和gridDnD(重复行) [英] jqGrid: Combining sortableRows and gridDnD (Duplicate Rows)

查看:121
本文介绍了jqGrid:组合sortableRows和gridDnD(重复行)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够将项目从Grid1拖动到Grid2,然后允许用户对Grid2的项目进行排序。单独地,sortableRows选项和gridDnd选项可以正常工作。当两个集成一起使用并且用户对Grid2中的行进行排序时,行将被复制,就好像它们是从Grid1拖动一样。

I want to be able to drag items from Grid1 to Grid2 and then allow the user to sort the items of Grid2. Individually, the sortableRows option and gridDnd options work without issue. When both integrations are used together and the user sorts the rows within Grid2, the rows are duplicated as if they were dragged from Grid1.

使用jquery 1.4.4,jqueryui 1.8 .10,jqGrid 4.2
以下是一些展示问题的示例代码:

Using jquery 1.4.4, jqueryui 1.8.10, jqGrid 4.2 Here is some sample code demonstrating the issue:

<script type="text/javascript">
$(document).ready(function () {
    // Creating grid1
    jQuery("#grid1").jqGrid({
        datatype: "local",
        height: 100,
        colNames: ['Id1', 'Name1', 'Values1'],
        colModel: [
           {name: 'id1', index: 'id',width: 100}, 
           {name: 'name1',index: 'name',width: 100},
           {name: 'values1',index: 'values',width: 200}
        ],
        caption: 'Grid 1',
        pager: '#pgrid1'
    });

    // Creating grid2
    jQuery("#grid2").jqGrid({
        datatype: "local",
        height: 'auto',
        colNames: ['Id2', 'Name2', 'Values2'],
        colModel: [
           {name: 'id2',index: 'id',width: 100},
           {name: 'name2',index: 'name', width: 100},
           {name: 'values2',index: 'values',width: 200}],
        caption: 'Grid 2',
        pager: '#pgrid2'
    });

    // Data for grid1
    var mydata1 = [
        {id1:"1",name1:"test1",values1:'One'},
        {id1:"2",name1:"test2",values1:'Two'},
        {id1:"3",name1:"test3",values1:'Three'}
    ];

    // Data for grid2
    var mydata2 = [
        {id2:"11",name2:"test11",values2:'One1'},
        {id2:"21",name2:"test21",values2:'Two1'},
        {id2:"31",name2:"test31",values2:'Three1'}
    ];

    // Adding grid data
    for (var i = 0; i <= mydata1.length; i++) {
        jQuery("#grid1").jqGrid('addRowData',i + 1, mydata1[i]);
        jQuery("#grid2").jqGrid('addRowData',i + 1, mydata2[i]);
    }

    // connect grid1 with grid2
    jQuery("#grid1").jqGrid('gridDnD',{connectWith:'#grid2'});
    // make grid2 sortable
    jQuery("#grid2").jqGrid('sortableRows');

});

</script>
<table id="grid1">
    <tr>
        <td />
    </tr>
</table>
<table id="grid2">
    <tr>
        <td />
    </tr>
</table>


推荐答案

这似乎是jqGrid代码中的一个错误。我认为应该更改一行 392 grid.jqueryui.js 来自

It seems a bug in the jqGrid code. I think that one should change the line 392 of the grid.jqueryui.js from

return d;

return false;

jquery.jqGrid.src.js 的编号为11098.更改后原始演示将修复为以下似乎工作正常。

The corresponding line in the jquery.jqGrid.src.js has the number 11098. After the changes the original demo will be fixed to the following which seems work correct.

更新:我发布了三角形论坛中的错误报告我描述了问题和我的建议要解决这个问题。我希望Tony能将修复包含在jqGrid的主代码中。

UPDATED: I posted the bug report in the trirand forum where I described the problem and my suggestion to fix it. I hope that Tony will include the fix in the main code of jqGrid.

UPDATED 2 :该错误已经已修复 jqGrid的主要代码。

UPDATED 2: The bug is already fixed in the main code of jqGrid.

这篇关于jqGrid:组合sortableRows和gridDnD(重复行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆