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

查看:21
本文介绍了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天全站免登陆