How to set focus on specific cell in onSelectRow in inline edit jqgrid?
I have tried the answers from:
1. Need jqGrid inline editing to have focus go to clicked cell
2. How to set focus to cell which was clicked to start inline edit in jqgrid
3. How to edit the selected cell on jqGrid
4. Set the focus to the editable input field on select row in jqgrid
but none of that works!
So now I don't need to find what cell the user clicked, but I need the cursor to be exactly in "lg_description" column for each row. Which I guess the problem is with the e parameter, and I think when I set it to "lg_description" column, I just need to attach "lg_description" somewhere instead of e parameter.
EDITED:
This is my code:
onSelectRow: function(id, status, e){
var grid = $(this);
if(id && id!==lastSel){
grid.restoreRow(lastSel);
lastSel=id;
//cursor focus
//first attemp: $("#lg_description").focus();
//second attemp: $("input, select",e.target).focus();
//third attemp: document.getElementById("lg_description").focus();
//fourth attemp:
/*var setFocusToCell = function(e) {
if(!e || !e.target) return;
var $td = $(e.target).closest("td"), $tr = $td.closest("tr.jqgrow"), ci, ri, rows = this.rows;
if ($td.length === 0 || $tr.length === 0 || !rows) return;
ci = $.jgrid.getCellIndex($td[0]);
ri = $tr[0].rowIndex;
$(rows[ri].cells[ci]).find("input,select").focus();
}
setFocusToCell(e);*/
}
grid.editRow(id, true,"","","","",aftersavefunc);
//fifth attemp: grid.editRow(id, true,function() {$("#lg_description").focus();},"","","",aftersavefunc);
},
I have tried 5 different attemps where the fifth one is a substitute for the code above it
lg_description
. Where is the corresponding code? Do you tried to place.focus()
call inside ofsetTimeout()
? Typically the setting of focus with small timeout work always. – OlegeditRow
which creates the input fields if inline editing. Moreover I asked you to insert more full code which you use. It's strange why you try to use$("#lg_description").focus();
withlg_description
to set the focus. Is the rowid of the editing rowlg
? Is the column name isdescription
? Could you include more full code which you use? At leastcolModel
and test data for the grid (2 rows are enough) are required. – Oleg