jqGrid example 可直接运行,简单范例

6 篇文章 0 订阅
3 篇文章 0 订阅

转载自:https://github.com/searls/jqgrid-example

<html>
  <head>
    
    <link rel="stylesheet" type="text/css" media="screen" href="css/jquery-ui-1.8.12.custom.css" />    
    <link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
    
    <script src="js/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
    <script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
    <script src="json-load-once.js" type="text/javascript"></script>
  </head>
  
  
  
  <body>
  </body>
</html>
json-load-once.js中内容如下
(function($){
  $(function(){
    $('<table id="myTable"></table><div id="pager"></div>').appendTo('body');
    
    $('#myTable').jqGrid({
      url:'some.json',
      datatype: "json",
      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"},
      {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}		
      ],
      rowNum:20,
      rowList:[10,20,30],
      pager: '#pager',
      sortname: 'id',
      viewrecords: true,
      sortorder: "desc",
      loadonce: true,
      caption: "Load Once Example"
    });


  });
})(jQuery);  
 
some.json中内容如下:
{"page":"1","total":1,"records":"13","rows":[{"id":"13","cell":["13","2007-10-06","Client 3","1000.00","0.00","1000.00",null]},{"id":"12","cell":["12","2007-10-06","Client 2","700.00","140.00","840.00",null]},{"id":"11","cell":["11","2007-10-06","Client 1","600.00","120.00","720.00",null]},{"id":"10","cell":["10","2007-10-06","Client 2","100.00","20.00","120.00",null]},{"id":"9","cell":["9","2007-10-06","Client 1","200.00","40.00","240.00",null]},{"id":"8","cell":["8","2007-10-06","Client 3","200.00","0.00","200.00",null]},{"id":"7","cell":["7","2007-10-05","Client 2","120.00","12.00","134.00",null]},{"id":"6","cell":["6","2007-10-05","Client 1","50.00","10.00","60.00",""]},{"id":"5","cell":["5","2007-10-05","Client 3","100.00","0.00","100.00","no tax at all"]},{"id":"4","cell":["4","2007-10-04","Client 3","150.00","0.00","150.00","no tax"]},{"id":"3","cell":["3","2007-10-02","Client 2","300.00","60.00","360.00","note invoice 3 & and amp test"]},{"id":"2","cell":["2","2007-10-03","Client 1","200.00","40.00","240.00","note 2"]},{"id":"1","cell":["1","2007-10-01","Client 1","100.00","20.00","120.00","note 1"]},{"id":"13","cell":["13","2007-10-06","Client 3","1000.00","0.00","1000.00",null]},{"id":"12","cell":["12","2007-10-06","Client 2","700.00","140.00","840.00",null]},{"id":"11","cell":["11","2007-10-06","Client 1","600.00","120.00","720.00",null]},{"id":"10","cell":["10","2007-10-06","Client 2","100.00","20.00","120.00",null]},{"id":"9","cell":["9","2007-10-06","Client 1","200.00","40.00","240.00",null]},{"id":"8","cell":["8","2007-10-06","Client 3","200.00","0.00","200.00",null]},{"id":"7","cell":["7","2007-10-05","Client 2","120.00","12.00","134.00",null]},{"id":"6","cell":["6","2007-10-05","Client 1","50.00","10.00","60.00",""]},{"id":"5","cell":["5","2007-10-05","Client 3","100.00","0.00","100.00","no tax at all"]},{"id":"4","cell":["4","2007-10-04","Client 3","150.00","0.00","150.00","no tax"]},{"id":"3","cell":["3","2007-10-02","Client 2","300.00","60.00","360.00","note invoice 3 & and amp test"]},{"id":"2","cell":["2","2007-10-03","Client 1","200.00","40.00","240.00","note 2"]},{"id":"1","cell":["1","2007-10-01","Client 1","100.00","20.00","120.00","note 1"]},{"id":"13","cell":["13","2007-10-06","Client 3","1000.00","0.00","1000.00",null]},{"id":"12","cell":["12","2007-10-06","Client 2","700.00","140.00","840.00",null]},{"id":"11","cell":["11","2007-10-06","Client 1","600.00","120.00","720.00",null]},{"id":"10","cell":["10","2007-10-06","Client 2","100.00","20.00","120.00",null]},{"id":"9","cell":["9","2007-10-06","Client 1","200.00","40.00","240.00",null]},{"id":"8","cell":["8","2007-10-06","Client 3","200.00","0.00","200.00",null]},{"id":"7","cell":["7","2007-10-05","Client 2","120.00","12.00","134.00",null]},{"id":"6","cell":["6","2007-10-05","Client 1","50.00","10.00","60.00",""]},{"id":"5","cell":["5","2007-10-05","Client 3","100.00","0.00","100.00","no tax at all"]},{"id":"4","cell":["4","2007-10-04","Client 3","150.00","0.00","150.00","no tax"]},{"id":"3","cell":["3","2007-10-02","Client 2","300.00","60.00","360.00","note invoice 3 & and amp test"]},{"id":"2","cell":["2","2007-10-03","Client 1","200.00","40.00","240.00","note 2"]},{"id":"1","cell":["1","2007-10-01","Client 1","100.00","20.00","120.00","note 1"]},{"id":"13","cell":["13","2007-10-06","Client 3","1000.00","0.00","1000.00",null]},{"id":"12","cell":["12","2007-10-06","Client 2","700.00","140.00","840.00",null]},{"id":"11","cell":["11","2007-10-06","Client 1","600.00","120.00","720.00",null]},{"id":"10","cell":["10","2007-10-06","Client 2","100.00","20.00","120.00",null]},{"id":"9","cell":["9","2007-10-06","Client 1","200.00","40.00","240.00",null]},{"id":"8","cell":["8","2007-10-06","Client 3","200.00","0.00","200.00",null]},{"id":"7","cell":["7","2007-10-05","Client 2","120.00","12.00","134.00",null]},{"id":"6","cell":["6","2007-10-05","Client 1","50.00","10.00","60.00",""]},{"id":"5","cell":["5","2007-10-05","Client 3","100.00","0.00","100.00","no tax at all"]},{"id":"4","cell":["4","2007-10-04","Client 3","150.00","0.00","150.00","no tax"]},{"id":"3","cell":["3","2007-10-02","Client 2","300.00","60.00","360.00","note invoice 3 & and amp test"]},{"id":"2","cell":["2","2007-10-03","Client 1","200.00","40.00","240.00","note 2"]},{"id":"1","cell":["1","2007-10-01","Client 1","100.00","20.00","120.00","note 1"]}],"userdata":{"amount":3820,"tax":462,"total":4284,"name":"Totals:"}}

 
如需整个案例请去https://github.com/searls/jqgrid-example地址下载

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值