【发布时间】:2015-05-29 22:07:36
【问题描述】:
我正在处理一项需要更新 jqgrid 中的整行数据的任务。
这是一个 fiddler 示例:https://jsfiddle.net/99x50s2s/47/
在上面的fiddler中,请更新一行,然后尝试向右滚动。
代码:
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]);
我想知道如何解决此问题?任何帮助表示赞赏。
注意:
jqGrid 版本:4.6.0 已应用:冻结列和单元格文本换行。
编辑:
从提琴手拍摄的带有解决方案的快照:
【问题讨论】:
标签: javascript jquery jqgrid