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>
展开
 我来答
shenchaoliang
2014-02-10 · TA获得超过1163个赞
知道大有可为答主
回答量:810
采纳率:0%
帮助的人:1515万
展开全部

加载完数据再重新reload就行

for(var i=0;i<=mydata.length;i++){

  jQuery("#jqGrid").jqGrid('addRowData',i+1,mydata[i]);

 } 

$("#jqGrid").setGridParam({ rowNum: 30 }).trigger("reloadGrid");
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式