mailazs
mailazs

Reputation: 341

jqGrid: Select the text of a row on inline editing

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.

Upvotes: 1

Views: 2690

Answers (4)

Arun Pratap Singh
Arun Pratap Singh

Reputation: 3646

// 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.            
        }
        ...
        ..

    });

Upvotes: 0

PK-Albany
PK-Albany

Reputation: 23

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.

Upvotes: 0

Oleg
Oleg

Reputation: 221997

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.

Upvotes: 2

Rob
Rob

Reputation: 5588

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/

Upvotes: 0

Related Questions