Discuz教程网

jqGrid jQuery 表格插件测试代码

[复制链接]
authicon dly 发表于 2011-9-8 16:38:12 | 显示全部楼层 |阅读模式
官方Demo地址:http://www.trirand.com/blog/jqgrid/jqgrid.html
效果图:

页面代码:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>本地数据</title>
  5. <link href="css/redmond/jquery-ui-1.8.14.custom.css" rel="Stylesheet" />
  6. <link href="css/ui.jqgrid.css" rel="Stylesheet" />
  7. <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
  8. <script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>
  9. <script type="text/javascript" src="js/jquery.jqGrid.min.js"></script>
  10. <script type="text/javascript">
  11. $(document).ready(function(){
  12. $("#list1").jqGrid({
  13. datatype:"local",
  14. height:250,
  15. colNames:['自动编号','地区编号','地区名称','所属城市编号'],
  16. colModel:[ //这一项比较重要, 其中的name属性主要是用于后期的页面代码(注意这里的范围是本页面上的代码,不会涉及到后台代码), 而index属性是则是用于涉及后台时,给后台传递排序字段
  17. {name:'id',index:'id',width:60,sorttype:"int"},
  18. {name:'areaID',index:'areaID',width:80,sortable:false}, //sortable是该字段是否排序
  19. {name:'area',index:'area',width:180},
  20. {name:'father',index:'father',width:100,sortable:false} //colModel两个最主要就是1:name前台js用,2:index给后台传递排序字段
  21. ],
  22. multiselect:true, //是否允许多选择多项
  23. caption:"中国各城市的主要地区" //表格的标题文字
  24. });
  25. var mydata=[
  26. {id:"1",areaID:'110101',area:'东城区',father:'110100'},
  27. {id:"2",areaID:'110102',area:'西城区',father:'110100'},
  28. {id:"3",areaID:'110103',area:'崇文区',father:'110100'},
  29. {id:"4",areaID:'110104',area:'宣武区',father:'110100'},
  30. {id:"5",areaID:'110105',area:'朝阳区',father:'110100'},
  31. {id:"6",areaID:'110106',area:'丰台区',father:'110100'},
  32. {id:"7",areaID:'110107',area:'石景山区',father:'110100'},
  33. {id:"8",areaID:'110108',area:'海淀区',father:'110100'},
  34. {id:"9",areaID:'110109',area:'门头沟区',father:'110100'},
  35. {id:"10",areaID:'110111',area:'房山区',father:'110100'}
  36. ];
  37. for(var i=0; i<mydata.length; i++) //循环给每行添加数据
  38. {
  39. $("#list1").jqGrid('addRowData',i+1,mydata[i]);
  40. }
  41. });
  42. </script>
  43. </head>
  44. <body>
  45. <table id="list1"></table>
  46. <div id="pager1"></div>
  47. </body>
  48. </html>
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x



上一篇:js 函数的副作用分析
下一篇:读jQuery之十三 添加事件和删除事件的核心方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-2 16:19

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表