Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by dan on Nov 24, 2008 22:09
open dhtmlx forum
onRowSelect and onRowDblClick

Hi,
I have a dhtml grid. now in one particular field I want to fire two events. OnSingleClick I want to change the value of the field and on double click I am opening one highslide. But it is behaving strangely. SingleClick event always fires doesn't matter I am calling onRowSelect or onRowDblClicked. Code is as follows:

            function oneClick(ProwId,PcellId)
            {
                flag=false;
                grdMainAstEmpAvail.attachEvent("onRowDblClicked",doubleClick);
                if(!flag){
                    grdMainAstEmpAvail.cells(ProwId,PcellId).setValue('oneclick');
                }
            }
            function doubleClick(ProwId,PcellId)
            {
                flag=true;
                grdMainAstEmpAvail.cells(ProwId,PcellId).setValue('doubleclick');
            }



Please help.

Thanks and Regards,
Dan
Answer posted by Support on Nov 25, 2008 02:00

Unfortunately the browsers doesn't really separate double-click from single-click.
When you double-click on the cell - browser sends a single-click event as well, which result in both handlers execution. 

To resolve issue, you can use code as.

var click_flag;
mygrid.attachEvent("onRowSelect",function(){
         if (click_flag) click_flag=window.clearTimeout(click_flag)
         click_flag=window.setTimeout(oneClick,300);
})
mygrid.attachEvent("onRowDblClicked",function(){
         if (click_flag) click_flag=window.clearTimeout(click_flag)
         doubleClick();
})