Hi,
I wanted to add a new row on click of add button at the start of the grid
But the row are added at the bottom of the grid
Please tell me what I am doing wrong, so that the rows will be displayed at the start of the grid
jQuery(document).ready(function(){
jQuery("#list4″).jqGrid({
datatype: "local",
height: "150″,
colNames:['Date', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[
{name:'invdate',index:'invdate', width:90, sorttype:"date"},
{name:'name',index:'name', width:100},
{name:'amount',index:'amount', width:80, align:"right",sorttype:"float"},
{name:'tax',index:'tax', width:80, align:"right",sorttype:"float"},
{name:'total',index:'total', width:80,align:"right",sorttype:"float"},
{name:'note',index:'note', width:150, sortable:false}
],
multiselect: true,
scroll :1,
caption: "Manipulating Array Data"
});
var mydata = [
{invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
{invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
{invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
{invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
{invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
{invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
{invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
{invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
{invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}
];
for(var i=0;i<=mydata.length;i++)
jQuery("#list4″).jqGrid('addRowData',i+1,mydata[i]);
});
function add(){
var mydataadd =
[
{ida:"10",invdate:"2007-11-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
{ida:"11",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}
];
jQuery("#list").addRowData("ida",mydataadd, 'first');
}
</script>
</head>
<body>
<table id="list4″ class="scroll"></table>
<input type="button" onclick = "javascript:add();" value ="add" />
Thanks & Regards,
Viral Gala