jqgrid 数组 分页
jqgrid获取数组数据,怎么分页显示?<scripttype="text/javascript">jQuery(document).ready(function(){j...
jqgrid获取数组数据,怎么分页显示?
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#jqGrid").jqGrid({
data: mydata,
datatype: "local",
height: 250,
rowNum: 30,
rowList: [10,20,30],
colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[
{name:'id',index:'id', width:60, sorttype:"int"},
{name:'invdate',index:'invdate', width:90, sorttype:"date", formatter:"date"},
{name:'name',index:'name', width:100, editable:true},
{name:'amount',index:'amount', width:80, align:"right",sorttype:"float", formatter:"number", editable:true},
{name:'tax',index:'tax', width:80, align:"right",sorttype:"float", editable:true},
{name:'total',index:'total', width:80,align:"right",sorttype:"float"},
{name:'note',index:'note', width:150, sortable:false}
],
pager: "#pager",
viewrecords: true,
sortname: 'id',
grouping:true,
groupingView : { groupField : ['id'] },
imgpath: 'images',
caption:"镜花水月"
});
var mydata = [{id:"1",invdate:"2010-05-24",name:"test",note:"note",tax:"10.00",total:"2111.00"} ,
{id:"2",invdate:"2010-05-25",name:"test2",note:"note2",tax:"20.00",total:"320.00"},
{id:"3",invdate:"2007-09-01",name:"test3",note:"note3",tax:"30.00",total:"430.00"},
…………
];
for(var i=0;i<=mydata.length;i++){
jQuery("#jqGrid").jqGrid('addRowData',i+1,mydata[i]);
}
});
</script >
</head>
<body>
<div align="center">
<div style="width:250px;align: center" >
<table id="jqGrid" class="scroll" cellpadding="1" cellspacing="1"></table>
<div id="pager"></div>
</div>
</div> 展开
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#jqGrid").jqGrid({
data: mydata,
datatype: "local",
height: 250,
rowNum: 30,
rowList: [10,20,30],
colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[
{name:'id',index:'id', width:60, sorttype:"int"},
{name:'invdate',index:'invdate', width:90, sorttype:"date", formatter:"date"},
{name:'name',index:'name', width:100, editable:true},
{name:'amount',index:'amount', width:80, align:"right",sorttype:"float", formatter:"number", editable:true},
{name:'tax',index:'tax', width:80, align:"right",sorttype:"float", editable:true},
{name:'total',index:'total', width:80,align:"right",sorttype:"float"},
{name:'note',index:'note', width:150, sortable:false}
],
pager: "#pager",
viewrecords: true,
sortname: 'id',
grouping:true,
groupingView : { groupField : ['id'] },
imgpath: 'images',
caption:"镜花水月"
});
var mydata = [{id:"1",invdate:"2010-05-24",name:"test",note:"note",tax:"10.00",total:"2111.00"} ,
{id:"2",invdate:"2010-05-25",name:"test2",note:"note2",tax:"20.00",total:"320.00"},
{id:"3",invdate:"2007-09-01",name:"test3",note:"note3",tax:"30.00",total:"430.00"},
…………
];
for(var i=0;i<=mydata.length;i++){
jQuery("#jqGrid").jqGrid('addRowData',i+1,mydata[i]);
}
});
</script >
</head>
<body>
<div align="center">
<div style="width:250px;align: center" >
<table id="jqGrid" class="scroll" cellpadding="1" cellspacing="1"></table>
<div id="pager"></div>
</div>
</div> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询