在jqGrid中组合tableToGrid和gridDnd [英] Combining tableToGrid and gridDnd in jqGrid

查看:404
本文介绍了在jqGrid中组合tableToGrid和gridDnd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在jqGrid中使用tableToGrid方法创建两个网格.现在,我希望将行拖放到这两个网格之间.仅在选项中添加'gridDnD' : true无效.怎么做?

I'm creating two grids with the tableToGrid method in jqGrid. Now I'd like the rows to be drag and drop-able between these two grids. Simply adding 'gridDnD' : true in the options does not work. How is it done?

示例:

<script type="text/javascript">
$(function() {
tableToGrid("#table1", { gridDnD: {connectWith: "#table2" } });
tableToGrid("#table2", { gridDnD: {connectWith: "#table2" } });
}
</script>

<table id="table1">
<thead>
<tr>
<th>Col 1</th>
<th>Col 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Val 1</td>
<td>Val 2</tr>
</tr>
</tbody>
</table>

<table id="table2">
<thead>
<tr>
<th>Col 1</th>
<th>Col 2</th>
</tr>
</thead>
</table>

推荐答案

gridDnD is a method of jqGrid and not an option which you can use in tableToGrid directly. So you have to rewrite the code to something like the following:

tableToGrid("#table1");
tableToGrid("#table2");
$("#table1").jqGrid('gridDnD', {connectWith: "#table2"});
$("#table2").jqGrid('gridDnD', {connectWith: "#table1"});

请参见演示.

更新:我分析了在拖放过程中对行进行复制而不是对移动的问题.该问题似乎是jqGrid与版本1.8.13开始的jQuery UI的兼容性问题.您如何在使用jQuery UI 1.8.12的演示上看到代码正常工作.

UPDATED: I analysed the problem with coping of rows during drag&drop instead of moving. The problem seems be a compatibility problem of jqGrid with jQuery UI starting with Version 1.8.13. How you can see on the demo which uses jQuery UI 1.8.12 the code work correctly.

我发现 grid.jqueryui.js代码(jquery.jqGrid.src.js的第11078-11079行)

I found out that the lines of grid.jqueryui.js code (the lines 11078-11079 of jquery.jqGrid.src.js)

var ids = $(ui.helper).attr("id");
$($t).jqGrid('delRowData',ids );

是问题的根源. ui.helper[0]包含从jQuery UI 1.8.13开始的删除行具有空ID .

are the source of the problem. The ui.helper[0] contains the dropped row with empty id starting with jQuery UI 1.8.13.

如果您将代码更改为

var id = this.id;
$($t).jqGrid('delRowData',id);

该代码将在新的jQuery UI(经1.8.16测试)和旧的jQuery UI(1.8.12)中均可使用.请参见相应的演示此处.

the code will work in both new jQuery UI (tested with 1.8.16) and in the old one (1.8.12). See the corresponding demo here.

我目前没有时间更精确地分析jQuery UI 1.8.12和1.8.13之间的变化. jQuery UI中可能存在一个错误.不过,我将上述建议作为错误修正发布在 trirand论坛中.我认为最好有jqGrid代码,它与不同版本的jQuery UI的兼容性问题较少.

I have currently no time for more exact analyse of changes between jQuery UI 1.8.12 and 1.8.13. Probably there are a bug in jQuery UI. Nevertheless I will post my suggestion described above as the bugfix in the trirand forum. I think it will be good to have jqGrid code which has less compatibility problems with different versions of jQuery UI.

这篇关于在jqGrid中组合tableToGrid和gridDnd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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