Pregunta

I have a grid and I'm using PHP and JSON. I'm using ondblClickRow to do inline editing. The thing that I need is: when I double click in a field, I want the content of this field will be select. I'm sorry to ask about this, but I didn't find this... when I search it on Google I just find examples of select row and this issues.

¿Fue útil?

Solución

I recommend you to look this answer and another one. Probably modification of the code from the last answer to the web browser which you use will get your the solution of your problem.

Otros consejos

If you want a single cell to be focused after inline edit mode is enabled, try this:

ondblClickRow: function (rowId, rowIndex, columnIndex) {
  var grid = $('#mygrid');
  grid.editRow(rowId, true, function() {
    var colModel = grid.getGridParam('colMode');
    var colName = colModel[colIndex].name;
    var input = $('#' + rowId + '_' + colName);
    input.get(0).focus();
  });
}
}

Found the code here: http://www.trirand.com/blog/?page_id=393/help/setting-focus-on-a-cell-after-entering-edit-mode/

If you have specific columns in a grid when you click on it should select its contents, then in your colmodel add this code to each column:

{
    name: 'TEXT_BOX',
    index: 'TEXT_BOX',
    label: 'Notes',
    width: 100,
    align: 'left',
    sortable: false,
    hidden: false, 
    dataEvents: [ { type: 'click', data: { i: 7 }, fn: function(e) { e.target.select(); } }] 
}

dataEvents will select the text in the input field when you click on it.

// Text will get Selected of cell when inline editing 
    $('#gridTableObj').jqGrid({
        ....
        ..
        afterEditCell : function(rowid, cellname, value, iRow, iCol){
            $('#'+rowid+'_'+cellname).select(); // with this the edited cell value will be selected.            
        }
        ...
        ..

    });
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top