2

I'm facing a problem with jqGrid and I don't know if has an easy solution.

When I click on a row for the first time the app slideUp a header with information about the register, if I click again the app slideDown this header. This work is coded in the onSelectRow event of jqGrid and is working right.

The problem comes after, when I double click in a row. In this case the app slideUp all the content about the register with the header included. The behaviour which I want to prevent is the onSelectRow because When the ondblclickRow event is fired, the onSelectRow event was fired two times before.

this is the piece of my code:

ondblClickRow: function(id) {  
    if (model.gisgridmap.context.id=="griddiv" && $(".editbt").length>0) {                  
        if (model.selectedrow == id) {
            $el.trigger("onUnselectRow");   
            $(this).find(".ui-state-highlight, [aria-selected='true']").removeClass('ui-state-highlight');  
            model.selectedrow = 0;  
        }
        else{
            $el.trigger("onSelectRow", id);  
            $(this).find('[aria-selected=true]').addClass('ui-state-highlight');
            model.selectedrow = id;

            pui.editForm(model);
        } 
},
onSelectRow: function(id,status,e){
    if (model.selectedrow == id) {
        $el.trigger("onUnselectRow");   
        $(this).find(".ui-state-highlight, [aria-selected='true']").removeClass('ui-state-highlight');  
        model.selectedrow = 0;  
    }
    else{
        $el.trigger("onSelectRow", id);  
        $(this).find('[aria-selected=true]').addClass('ui-state-highlight');
        model.selectedrow = id;
    } 
}

Thanks in advance.

Shimon Rachlenko
  • 5,469
  • 40
  • 51
vmonrabal
  • 21
  • 1
  • 3

2 Answers2

0

You can try this :

ondblClickRow: function(id, status, e) {
    e.preventDefault(); // see : http://api.jquery.com/event.preventDefault
    e.stopPropagation(); // see : http://api.jquery.com/event.stopPropagation
    ...
}
zapcost
  • 1,336
  • 12
  • 5
0

Finally, I put a timeout on the dblclick wiht the enough time to show the header, after that the form slidesUp without strange behaviours. I couldn't solve the problem with the event firing as I wanted, but the solution was good.

           ondblClickRow: function(id, iRow, iCol, e) {
                pui._hideBar();
                if (model.gisgridmap.context.id=="griddiv" && $(".editbt").length>0) {                  
                    $(this).find('[aria-selected=true]').addClass('ui-state-highlight');
                    pui.showForm(model, id, false, model.gisgridmap.context.id);
                    setTimeout(function(){
                        model.selectedrow = id;
                        pui.editForm(model);
                    }, 400);                        
                }                    
            },
            onSelectRow: function(id,status,e){   
                if ($(this).jqGrid('getGridParam', 'multiselect')) {
                    $el.trigger("onSelectRow", id);
                    return;
                } 
                e.preventDefault();
                if (model.selectedrow == id) {
                    e.preventDefault();
                    $el.trigger("onUnselectRow");   
                    $(this).find(".ui-state-highlight, [aria-selected='true']").removeClass('ui-state-highlight');  
                    model.selectedrow = 0;  
                }
                else{
                    $el.trigger("onSelectRow", id);  
                    $(this).find('[aria-selected=true]').addClass('ui-state-highlight');
                    model.selectedrow = id;
                } 
            }

Best regards.

vmonrabal
  • 21
  • 1
  • 3