1

After I inserted a new row using

my_table.jqGrid('addRowData', selected_rowid+1, newRow, 'after', selected_rowid);

The new row is inserted correctly on the table but when I output the grid data

my_table.getGridParam('data')

the new row is inserted in the very end of the data array. Also, when I click any row after the new row inserted, the rowid was not updated (incremented).

Is there any way to fix this?

The grid definition is this:

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,   
        });

I read a previous post and it seems like i can pass in "undefined" as the rowid. The problem is I want to have the ids sorted correctly. So if I insert a row after rowid of 7, the new row should have rowid of 8 and the rest should all be pushed back by one. Is this possible with jqGrid?

4

0 回答 0