1

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');
    }
}
mayur
  • 47
  • 1
  • 3
  • 11

1 Answers1

1

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):

It is inadvisable to bind handlers to both the click and dblclick events for the same element. The sequence of events triggered varies from browser to browser, with some receiving two click events before the dblclick and others only one. Double-click sensitivity (maximum time between clicks that is detected as a double click) can vary by operating system and browser, and is often user-configurable.

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.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thanks for the help ...!! Have removed similar code from beforeSelectRow (which was useful though), thus now not getting that problem.. but still using some timeout and all, can't we prevent the click event for double click.. ?? – mayur Apr 26 '12 at 06:44
  • Sorry, for the accept miss.. except this question, i did for all your other answers... i just missed this one.. !! Was speaking about jquery's settimeout function.. By giving some time out, using setTimeOut function, in click event.. can't we prevent execution of click event code, on doubleclick .. – mayur Apr 26 '12 at 08:15
  • @mayur: The double-click will be fire *after* the click so it's **too late** to do some action to prevent the click event. You should reorganize your code so that the problem which you want to prevent don't exist at all. I can't explain more detailed because you don't described in details what your program do in both event handlers and why the problem exist. Moreover you should be accurate. The are JavaScript function `setTimeout` and no "jquery's settimeout function" or "setTimeOut function". I think that you should explain your existing problem on an code example. – Oleg Apr 26 '12 at 08:23
  • As per my first comment.. i have organized the code properly.. and now.. m not facing any problem.. was asking this for curiosity sake.. so that if in future, again such problems arise in any other plugins ..!! and again you are right.. its javascript function only.. !! – mayur Apr 26 '12 at 08:30
  • @mayur: I can try to help you to solve theome problem only if I'll see the code which shows exactly what you do. Sorry, but after all your explanations I still have no idea what your program do inside on row selection and on double-click and why you have the problem at all, so I just unable to help you. – Oleg Apr 26 '12 at 08:40
  • Its alright.. as i have changed the code.. and organized properly as you told.. i can't get you the one giving problem.. but anywayz.. thanks for the help.. !! – mayur Apr 26 '12 at 09:05
  • @mayur: You are welcome! It's good to know that the problem is solved. – Oleg Apr 26 '12 at 09:25