jQGrid拖放行检查 [英] jQGrid Drag and Drop Row Check

查看:139
本文介绍了jQGrid拖放行检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的主要网格将行正确拖放到辅助网格中。我的问题是,如何在将行放入辅助网格之前执行检查,这将决定我试图删除的行是否已经存在?如果它已经在次级网格中,不要让用户将其放在那里,基本上停止拖放功能。

I have my primary grid dragging/dropping rows correctly into a secondary grid. My question is, how do I perform a check just before the row is dropped into my secondary grid, which determines if the row I am attempting to drop is already there? If it is already there in the secondary grid, don't let the user drop it there, basically stop the drag/drop function.

我想我可以抢我试图放弃的行中的关键值。然后,检查该值是否已经存在,作为我已经删除的行之一的键值。我假设我将以某种方式使用此功能:

I'm thinking I can grab the key value from the row I am attempting to drop. Then, check to see if that value already exists as the key value in one of the rows I already dropped. I'm assuming I will have to use this function in some way:

beforedrop : function(e,ui,data,source,target) { }

或此功能:

ondrop: function (ev, ui, getdata) { }

任何人都有任何想法?

推荐答案

使用示例可能是以下

$("#grid1").jqGrid('gridDnD', {
    connectWith: '#grid2',
    beforedrop: function (ev, ui, getdata, $source, $target) {
        var names = $target.jqGrid('getCol', 'name2');
        if ($.inArray(getdata.name2, names) >= 0) {
            // prevent data for dropping
            ui.helper.dropped = false;
            alert("The row is already in the destination grid");
        }
    }
});

演示,您将无法将行test1从第一个网格删除到第二个网格:

On the demo you would be unable to drop the rows "test1" from the first grid to the second one:

其他行将被删除,没有任何问题。

Other rows will be dropped without any problems.

这篇关于jQGrid拖放行检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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