15

In this demo of jqGrid, when you click on the "Edit Selected Row" button:

enter image description here

it brings up an edit form.

enter image description here

Is there any way to double click on a row in the grid to bring up this same edit form?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
leora
  • 188,729
  • 360
  • 878
  • 1,366

4 Answers4

35

It can be very simple implemented as

ondblClickRow: function(rowid) {
    jQuery(this).jqGrid('editGridRow', rowid);
}

you can also use any additional properties of editGridRow described in the documentation. For example

ondblClickRow: function(rowid) {
    jQuery(this).jqGrid('editGridRow', rowid,
                        {recreateForm:true,closeAfterEdit:true,
                         closeOnEscape:true,reloadAfterSubmit:false});
}
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • as a jqgrid expert, do you have any thoughts on this question: http://stackoverflow.com/questions/4876433/does-jqgrid-support-a-multiple-checkbox-list-for-editing – leora Feb 13 '11 at 12:57
  • also, this seems to be a complete mystery: http://stackoverflow.com/questions/4982992/when-editing-a-row-using-jqgrid-why-doesnt-my-combobox-default-to-the-existing – leora Feb 13 '11 at 13:19
  • @Oleg , I really like the `ondblClickRow` performing the cell edit. How would one cause the even of selecting a ***different*** cell to cause the save of the cell under edit? – blong Aug 31 '11 at 15:02
  • 1
    @Brian L.: I hope all which you wrote was about [inline editing](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing) and not [cell editing](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:cell_editing). If I understand you correct you need just implement `onSelectRow`, `onCellSelect` or `beforeSelectRow` event handler where you compare the id of the last edited row with the id of the current clicked row. If the ids are different you can call [saveRow](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#saverow) to save last edited row. – Oleg Aug 31 '11 at 15:16
  • @Oleg: Yes, I'm sorry I wrote that incorrectly. Writing the event handlers sounds right to me, I'm going to try my hand at it - I'll follow-up asap. Thanks again for the help! – blong Aug 31 '11 at 15:40
2

simple way

ondblClickRow : function(rowid) {
    $("#edit_mygridId").trigger("click");
}
0

check answers of similar questions:

jqGrid Cell Editing - Double Click to Edit?

jqGrid: replace single click with double click to enter cell edit mode

Community
  • 1
  • 1
  • Costa De Oliveir - how do you differentiate if you want the popup form versus inline cell editing ?? – leora Feb 13 '11 at 06:29
  • 1
    grid edit: jQuery("#grid_id").editGridRow( rowid, properties ); inline edit: jQuery("#grid_id").editRow(rowid, keys, oneditfunc, succesfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc); check complete documentation http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing – Gustavo Costa De Oliveira Feb 13 '11 at 07:27
0

Here a little more complex ondblClickRow, from my codes, this get the data from form and altered a varible before submit, also adding a variable before post.

ondblClickRow: function(rowid) {
jQuery(this).jqGrid('editGridRow', rowid,
{
recreateForm:true,
closeAfterEdit:true,
closeOnEscape:true,
reloadAfterSubmit:true,
url:"proc/jqgridUsers.php",
editCaption : "Edit User",
bottominfo : "Fields (*) are requeired ",
height:330,
width:350,
            beforeSubmit:function(postdata, formid){
            var dataString = $("#formid").serialize();
            var ord1 = document.getElementById('ord1').value;
            var ord2 = document.getElementById('ord2').value;
            var ordx = hex_sha1(hex_md5(document.getElementById('ord1').value));
            postdata.ord1 = ordx;
            postdata.ord2 = "";
            var boolcontrol = false;
            var message="";
                if (ord1!=ord2) {
            return [boolcontrol,"Password are not the same!!"];
                } else {
            boolcontrol = true;
                }
            return [boolcontrol,message]; // no error
 }                                                                                                                      
});
}
rpaillao
  • 193
  • 1
  • 2
  • 11