首页 > 代码库 > jqgrid学习琐记---shrinkToFit--特别的是

jqgrid学习琐记---shrinkToFit--特别的是

  <body>
  <div style="margin:30px;">
  <table id="list4"></table>
  <div id="pager5"></div>
  </div>
<br />
<a href=http://www.mamicode.com/"#" id="a1">Get data from selected row
<br />
<a href=http://www.mamicode.com/"#" id="a2">Delete row 2
<br />
<a href=http://www.mamicode.com/"#" id="a3">Update amounts in row 1
<br />
<a href=http://www.mamicode.com/"#" id="a4">Add row with id 99
<br />
</body>
<script type="text/javascript">
var mydata = http://www.mamicode.com/[
        {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"},
        {id:"5",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
        {id:"6",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
        {id:"7",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
        {id:"8",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
        {id:"9",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}/*,
        {id:"10",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
        {id:"11",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
        {id:"12",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
        {id:"13",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
        {id:"14",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
        {id:"15",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
        {id:"16",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
        {id:"17",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
        {id:"18",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
        {id:"19",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}*/
        ];
jQuery("#list4").jqGrid({
    datatype: ‘local‘,
    //dataStr:
    height:300,   
       colNames:[‘Inv No‘,‘Date‘, ‘Client‘, ‘Amount‘],
       colModel:[
           {name:‘id‘,index:‘id‘, width:60, sorttype:"int"},
           {name:‘invdate‘,index:‘invdate‘, width:90, sorttype:"date"},
           {name:‘name‘,index:‘name‘, width:100},
           {name:‘amount‘,index:‘amount‘, width:100, align:"right",sorttype:"float"},
          
       ],     
       pager: ‘#pager5‘,
       sortname: ‘id‘,
    viewrecords: true,
    sortorder: "desc",  
    shrinkToFit:true,
    scroll:true,
       caption: "Manipulating Array Data"
});

for(var i=0;i<=mydata.length;i++)
    jQuery("#list4").jqGrid(‘addRowData‘,i+1,mydata[i]);   
   
</script>

imageimage