In jqGrid, can you double click a row to bring up the edit form?
Asked Answered
J

4

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?

Jackstay answered 13/2, 2011 at 5:34 Comment(2)
possible duplicate of jqGrid Cell Editing - Double Click to Edit?Toler
great question - just what I was looking forAnalyze
F
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});
}
Forbidden answered 13/2, 2011 at 10:44 Comment(5)
as a jqgrid expert, do you have any thoughts on this question: #4876933Jackstay
also, this seems to be a complete mystery: #4983492Jackstay
@Forbidden , 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?Enclasp
@Brian L.: I hope all which you wrote was about inline editing and not 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 to save last edited row.Forbidden
@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!Enclasp
C
2

simple way

ondblClickRow : function(rowid) {
    $("#edit_mygridId").trigger("click");
}
Chamness answered 1/4, 2013 at 22:5 Comment(0)
E
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

Eyetooth answered 13/2, 2011 at 5:56 Comment(2)
Costa De Oliveir - how do you differentiate if you want the popup form versus inline cell editing ??Jackstay
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 trirand.com/jqgridwiki/doku.php?id=wiki:form_editing trirand.com/jqgridwiki/doku.php?id=wiki:inline_editingEyetooth
Y
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
 }                                                                                                                      
});
}
Yu answered 10/6, 2020 at 17:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.