I am working on a task where I need to update entire row data in jqgrid.
Here is a sample fiddler: https://jsfiddle.net/99x50s2s/47/
In the above fiddler, please update a row and then try to scroll to the right.
Code:
var $thisGrid = jQuery("#sg1");
$thisGrid.jqGrid({
datatype: "local",
gridview: true,
loadonce: true,
shrinkToFit: false,
autoencode: true,
height: 'auto',
width: 400,
viewrecords: true,
sortorder: "desc",
scrollrows: true,
loadui: 'disable',
colNames:["", 'Inv No', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[
{
name: "Symbol", index: "Symbol", width: 70, align: 'center', frozen: true,
formatter: function (cellValue, options, rowObject) {
return '<button class="btn btn-info btn-xs update" type="button" title="Update" >' +
'<span class="glyphicon glyphicon-remove-circle"></span> Update</button>';
}
},
{name:'id',width:60, sorttype:"int"},
{name:'name', width:100},
{name:'amount', width:80, align:"right",sorttype:"float"},
{name:'tax', width:80, align:"right",sorttype:"float"},
{name:'total', width:80,align:"right",sorttype:"float"},
{name:'note', width:150}
],
caption: "Test Data",
onCellSelect: function (rowid,
iCol,
cellcontent,
e) {
if (iCol == 0) {
var newdata = [
{id:"1",name:"new test1 name for testing purpose",note:"new note1",amount:"500.00",tax:"50.00",total:"510.00"},
];
$thisGrid.jqGrid('setRowData', rowid, newdata[0]);
}
}
}).jqGrid('setFrozenColumns');
var mydata = [
{id:"1",name:"test1",note:"note1",amount:"200.00",tax:"10.00",total:"210.00"},
{id:"2",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
{id:"3",name:"test3",note:"note3",amount:"400.00",tax:"25.00",total:"360.00"},
{id:"4",name:"test4",note:"note4",amount:"500.00",tax:"60.00",total:"350.00"},
{id:"5",name:"test5",note:"note5",amount:"600.00",tax:"70.00",total:"340.00"}
];
for(var i=0;i<=mydata.length;i++)
$thisGrid.jqGrid('addRowData',i+1,mydata[i]);
I am wondering how I can fix this behavior? Any help is appreciated.
Note:
jqGrid version: 4.6.0 Applied: Frozen column and cell text wrap.
EDIT:
snapshot taken from the fiddler with solution: