Hi,Tony
when the status of one cell was “cell Editing”,and click “remove this row” button,the row which was selected currently will be removed.
and select a new row randomly,
if there is one row which “row index” is the same as former(has been removed),the value of cell will be clear;
else the cell value of first row will be clear and grid’s “cell editing” feature will invalid.
jQuery(“#list4”).jqGrid({
datatype: “local”,
height: 250,
cellEdit: true,
cellsubmit: ‘clientArray’,
colNames:,
colModel:[
{name:’id’,index:’id’, width:60, sorttype:”int”},
{name:’invdate’,index:’invdate’, editable:true, width:90, sorttype:”date”},
{name:’name’,index:’name’, editable:true, width:100},
{name:’amount’,index:’amount’, editable:true, width:80, align:”right”,sorttype:”float”},
{name:’tax’,index:’tax’,editable:true,width:80,align:”right”,sorttype:”float”},
{name:’total’,index:’total’, editable:true,width:80,align:”right”,sorttype:”float”},
{name:’note’,index:’note’, editable:true, width:150, sortable:false}
],
imgpath: ‘images’,
toolbar: [true,’top’],
caption: “Cell Editing”
});
$(“#t_list4”).append(““);
var mydata = [ {id:”1″,invdate:”2007-10-01″,name:”test”,note:”note”,amount:”200.00″,tax:”10.00″,total:”210.00″} {id:”2″,invdate:”2007-10-02″,name:”test2″,note:”note2″,amount:”300.00″,tax:”20.00″,total:”320.00″}, {id:”3″,invdate:”2007-09-01″,name:”test3″,note:”note3″,amount:”400.00″,tax:”30.00″,total:”430.00″}, {id:”4″,invdate:”2007-10-04″,name:”test”,note:”note”,amount:”200.00″,tax:”10.00″,total:”210.00″}
];
for(var i=0;i<=mydata.length;i++)
jQuery("#list4").addRowData(i+1,mydata[i]);
//remove method
function removeRow(){
var id = jQuery("#list4").getGridParam('selrow');
if (id) {
var ret = jQuery("#list4").getRowData(id);
jQuery(“#list4”).delRowData(ret.id);
} else {
alert(“Please select row”);
}
}
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top