Have the jqGrid as below, problem is that getting the input html on save, due to not focusing out of the jqgrid (may be).
$(mygridId).jqGrid({
url: url,
datatype: "json",
mtype: 'GET',
colNames: ['ID', 'Name', 'Description'],
colModel: [
{
name: 'Id',
index: 'Id',
hidden: true
},
{
name: 'Name',
index: 'Name',
width: 25,
editable: true
},
{
name: 'Description',
index: 'Description',
width: 25,
search: false,
editable: true
}
],
cellEdit: true,
rownumWidth: 40,
gridview: true,
sortname: "Id",
autoencode: false,
cellsubmit: 'clientArray',
onCellSelect: function (rowId, iCol) {
theRow = rowId;
theColumn = iCol;
},
afterEditCell: function (rowid, cellname, value, iRow, iCol) {
theColumn = iCol;
theRow = rowid;
},
beforeEditCell: function (rowid, cellname, value, iRow, iCol) {
theColumn = iCol;
theRow = rowid;
},
jsonReader: {
repeatitems: false,
userdata: "rows",
page: "page",
total: "total",
records: "records"
}
});
$(mygridid).jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false, defaultSearch: "cn" });
When i add multiple rows, and click save button, focus won't be lost from the textbox, Hence, the saved value of the textbox will be
<input type="text" id="1_Description" name="Description" role="textbox" style="width: 98%;">
Any idea how to fix these?
Thanks in advace!
This is from same issue I answered elsewhere (see comments)...
This happens (sometimes) when inline (row or cell) editing is used in jqGrid. The implementation I used is https://github.com/free-jqgrid/jqGrid.
What happens is that the editor control is not cleared inside the "td" tag of the cell in the underlying "table" used by jqGrid. The cell will still show the entered/edited value once, but when the cell is entered again (clicked, tabbed, arrow keys, etc.), the text in the newly injected editor control will be the content (innerHTML?) of the "td" tag - which is the previous editor control HTML. This is what I see when this happens in both the grid and the HTML:
Note that this HTML is the TOP 2nd cell shown in the image, with the "ghost" editor in the cell.
I cannot confirm "why", but I was able to resolve this by using
setTimeout(). I know, I know... :-( It seems to have something to do with the "navigation" div element (header element) of the grid snapping focus back to it - I guess if the currently selected control doesn't have the "edited" CSS (and the header cannot be edited...), it won't/can't fully remove the input control?The
setTimeout()was put in the "afterEditCell" override (see code block below).I also gained stability by having empty implementations of the most of the cell editing override functions: