使用
插入新行后my_table.jqGrid('addRowData', selected_rowid+1, newRow, 'after', selected_rowid);
新行正确插入到表格中,但是当我输出网格数据时
my_table.getGridParam('data')
新行插入数据数组的最末端。此外,当我在插入新行后单击任何行时,rowid未更新(递增)。
有什么方法可以解决这个问题吗?
网格定义是:
my_table.jqGrid({
colNames:['Id', 'Start','End', 'Duration', 'Text','Position','Alignment','Warnings','Errors'],
colModel:[
{name:'rowid',index:'myrowid',hidden: true},
{name:'start',index:'startTime', width:10, formatter: convertTime},
{name:'end',index:'endTime', width:10, formatter: convertTime},
{name:'duration',index:'duration', width:10, formatter: getDuration},
{name:'data',index:'dataText', width:40, align:"middle", sortable:false, editable:true, edittype: 'text'},
{name:'position',index:'position', width:5,editable:true, sortable: false, edittype:'text'},
{name:'alignment',index:'alignment',width:5,editable:true, sortable: false,edittype:'text'},
{name:'warnings',index:'warnings',hidden: true, formatter: warnings},
{name:'errors',index:'errors',hidden: true, formatter: errors},
],
//pager: '#packagePager',
datatype: "local",
width: 700,
height: 800,
data: my.caption_data.rows,
localReader: {
id: "rowid",
repeatitems: true
},
rowNum: length,
viewrecords: true,
cellsubmit:'clientArray',
rownumbers:true,
hoverarrows: true,
multiselect: true,
cellEdit: false,
scrollrows : true,
multiboxonly:true,
autoencode:true,
});
我读了之前的post,好像我可以传入“undefined”作为rowid。问题是我想要正确排序ID。因此,如果我在rowid为7之后插入一行,则新行的rowid应为8,其余行应全部推回一。这有可能与jqGrid?