Search code examples
jqueryjqgridjqgrid-php

jqGrid: how to lose focus when i click outside the grid, or anywhere else for that matter


i'm currently doing editing using inline editing, and when i click outside the grid, it's still being under edit. what event handlers should i use to make it call the restore row function, such that the only way for data to actually sent to the server is if the user presses enter.

thx in advance


Solution

  • Anyway, i've figured out how to do it already. Just thought might be good to leave it somewhere online as I wasted quite a bit of time figuring out how to do it. Hope it helps =)

    $(document).click(function(e){
        if(e.target.id != lastSelectRoot+"_FieldName"){
            jQuery('#grid').jqGrid('restoreRow',lastSelectRoot);
            lastSelectRoot = null;
        }
    });
    

    Just add this piece of code somewhere and change the appropriate parts, such as FieldName and lastSelectRoot and #grid to what you are already using.