jqGrid Cell Editing - Double Click to Edit?
Asked Answered
F

2

5

By default, if a jqGrid cell is editable, single click on that cell changes it to edit mode. Is there any way I can make it edit on a double click instead? It would make it easier to do row-level operations such as deleting, as all the columns in my grid are editable.

Forestall answered 19/7, 2010 at 17:43 Comment(0)
D
8

Yes, you can use the ondblClickRow event to capture a double-click.

Here is a simple example to get you started:

ondblClickRow: function(){
    var row_id = $("#grid").getGridParam('selrow');
    jQuery('#grid').editRow(row_id, true);
}
Didynamous answered 19/7, 2010 at 17:48 Comment(3)
Thanks, but this is not quite what I had in mind. Looking at this code, it appears that this would bring up the form to edit the contents of an entire row, whereas I want to do inline editing of a single cell. Also, how would I disable the cell editing on a single click, while still retaining the ability to select the row with a single click?Forestall
editRow is for inline editing, not form editing. Also, in my grids I needed to explicitly call editRow from the onSelectRow event to enable editing via single-click. If you simply remove this code you will have disabled single-click. Just keep in mind that double-clicking to edit may not be intuitive to your users...Didynamous
Do you mean you removed the code from the jqGrid code itself? Also, you may be correct, but I don't really think that even single-clicking on text for editing is all that intuitive. At least in apps like Excel, editing a cell requires a double-click, so it's not without precedent. Thoughts?Forestall
R
2

I got the answer. You only need to place the code on the jqgrid properties For example:

width: 800,
        height: 200,
        caption:"   .:: Captura de Datos ::.",
        addedrow: "last",
        ondblClickRow: function (rowid, iRow,iCol) {
            alert('Doble Click');
            //jQuery("#TBLReporte").editCell(iRow, iCol, true);
        }
Revelry answered 4/6, 2014 at 23:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.