jQuery 表格插件jqGrid 本地数据
来源:广州中睿信息技术有限公司官网
发布时间:2012/10/21 23:25:16 编辑:editor 阅读 344
在逛博客中无意中看到这个插件,一下就吸引住了我,于是就自己在网上找了些资料实践了一下:官方Demo地址:http://www.trirand.com/blog/jqgrid/jqgrid.html效

在逛博客中无意中看到这个插件,一下就吸引住了我,于是就自己在网上找了些资料实践了一下:

官方Demo地址:http://www.trirand.com/blog/jqgrid/jqgrid.html

效果图:

页面代码:

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">    <html xmlns="http://www.w3.org/1999/xhtml">  <head>      <title>本地数据</title>      <link href="css/redmond/jquery-ui-1.8.14.custom.css" rel="Stylesheet" />      <link href="css/ui.jqgrid.css" rel="Stylesheet" />      <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>      <script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>      <script type="text/javascript" src="js/jquery.jqGrid.min.js"></script>      <script type="text/javascript">          $(document).ready(function(){              $("#list1").jqGrid({                  datatype:"local",                  height:250,                  colNames:['自动编号','地区编号','地区名称','所属城市编号'],                  colModel:[  //这一项比较重要, 其中的name属性主要是用于后期的页面代码(注意这里的范围是本页面上的代码,不会涉及到后台代码), 而index属性是则是用于涉及后台时,给后台传递排序字段                      {name:'id',index:'id',width:60,sorttype:"int"},                      {name:'areaID',index:'areaID',width:80,sortable:false},  //sortable是该字段是否排序                      {name:'area',index:'area',width:180},                      {name:'father',index:'father',width:100,sortable:false}  //colModel两个最主要就是1:name前台js用,2:index给后台传递排序字段                  ],                  multiselect:true,  //是否允许多选择多项                  caption:"中国各城市的主要地区"   //表格的标题文字              });              var mydata=[                  {id:"1",areaID:'110101',area:'东城区',father:'110100'},                  {id:"2",areaID:'110102',area:'西城区',father:'110100'},                  {id:"3",areaID:'110103',area:'崇文区',father:'110100'},                  {id:"4",areaID:'110104',area:'宣武区',father:'110100'},                  {id:"5",areaID:'110105',area:'朝阳区',father:'110100'},                  {id:"6",areaID:'110106',area:'丰台区',father:'110100'},                  {id:"7",areaID:'110107',area:'石景山区',father:'110100'},                  {id:"8",areaID:'110108',area:'海淀区',father:'110100'},                  {id:"9",areaID:'110109',area:'门头沟区',father:'110100'},                  {id:"10",areaID:'110111',area:'房山区',father:'110100'}              ];              for(var i=0; i<mydata.length; i++)  //循环给每行添加数据              {                  $("#list1").jqGrid('addRowData',i+1,mydata[i]);              }          });      </script>  </head>  <body>  <table id="list1"></table>  <div id="pager1"></div>  </body>  </html>
联系我们CONTACT 扫一扫
愿景:成为最专业的软件研发服务领航者
中睿信息技术有限公司 广州•深圳 Tel:020-38931912 务实 Pragmatic
广州:广州市天河区翰景路1号金星大厦18层中睿信息 Fax:020-38931912 专业 Professional
深圳:深圳市福田区车公庙有色金属大厦509~510 Tel:0755-25855012 诚信 Integrity
所有权声明:PMI, PMP, Project Management Professional, PMI-ACP, PMI-PBA和PMBOK是项目管理协会(Project Management Institute, Inc.)的注册标志。
版权所有:广州中睿信息技术有限公司 粤ICP备13082838号-2