本文介绍了防止beforeSelectRow事件,当用户双击jqgrid中的任何行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jqgrid中的单元格编辑,因此我正在使用许多不同的jqgrid事件,如下所述...
1)beforeSelectRow,2)beforeEditCell,3)afterEditCell,4)onCellSelect,5) ondblClickRow等...



现在,当我双击任何行时,beforeselectRow代码首先执行..我想要防止...但是如何这样做?



一些示例代码如下: -

  ondblClickRow:function(id,irow,icol,e)
{
........
},
beforeSelectRow:function(rowid,e)
{

if(rowid == lastSelected)
{
$ sampleDialog.dialog('open');
}
}


解决方案

Web浏览器以一些不同的方式处理双击事件。因此,一般来说,您不能在dblclick之前阻止点击事件。回调 beforeSelectRow 将被调用在中,位于jqGrid代码内部定义的 enevt处理程序。在 dblclick 事件处理程序的jQuery文档中,您可以阅读以下内容(请参阅):

您目前所做的只是不推荐的方式来绑定 'click'和'dblclick'句柄。



你没有描述你原来的问题,它可能在 ondblClickRow 回调实现之内。唯一的解决方案是检查程序的重组,以便在 beforeSelectRow ondblClickRow 回调之间的操作之间没有冲突。


I am using cell editing in jqgrid and for that, i am using many different jqgrid events, as mentioned below ...1) beforeSelectRow, 2)beforeEditCell, 3)afterEditCell, 4)onCellSelect, 5)ondblClickRow, etc...

Now, when i doubleClick on any of the row, the beforeselectRow code gets executed first.. which i want to prevent... but how to do that ??

Some example code is as below :-

ondblClickRow: function(id,irow,icol,e)
{
  ........
},
beforeSelectRow : function(rowid, e) 
{   

    if(rowid==lastSelected)
    {
        $sampleDialog.dialog('open');
    }
}
解决方案

Different web browsers process the double-click event in a little different ways. So in general you can't prevent 'click' event before 'dblclick'. The callback beforeSelectRow will be called inside of click enevt handler defined inside of jqGrid code. In jQuery documentation of dblclick event handler you can read the following (see here):

What you currently do is just not recommended way to binding both 'click' and 'dblclick' handles.

You don't describe the original problem which you has which is probably somewhere inside of ondblClickRow callback implementation. The only solution will be to examine reorganization of the program to have no collisions between the actions inside of beforeSelectRow and ondblClickRow callbacks.

这篇关于防止beforeSelectRow事件,当用户双击jqgrid中的任何行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 23:16