silolink.jsp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <%@ page contentType="text/html; charset=utf-8" session="false" %>
  2. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
  4. <head>
  5. <title>我的工作台</title>
  6. <%@ include file="../common/header.jsp" %>
  7. <script type="text/javascript">
  8. var mydata,operType;
  9. $(document).ready( function() {
  10. loadList(); //加载jqgrid
  11. $("#list").jqGrid("setGridHeight",$(window).height() - 105);
  12. $("#list").jqGrid("setGridWidth",document.body.clientWidth - 5);
  13. });
  14. $(window).resize(function(){
  15. $("#list").jqGrid("setGridHeight",$(window).height() - 105);
  16. $("#list").jqGrid("setGridWidth",document.body.clientWidth - 5);
  17. });
  18. //jqgrid初始化
  19. function loadList(){
  20. jQuery("#list").jqGrid({
  21. datatype: "local", //从服务器端返回的数据类型,(表格期望接收的数据类型)。可选类型:xml,xmlstring,json,local,function
  22. height: "70%", //高度
  23. colNames:["主键","精料仓名称","饲料","是否启用"], //列名
  24. colModel:[
  25. {
  26. name: "ID",
  27. index: "ID",
  28. align: "center",
  29. sorttype: "string",
  30. editable: true,
  31. hidden: true
  32. //editoptions:{readonly:true} 如果要显示该列可以设置只读
  33. },
  34. {
  35. name: "siloName",
  36. index: "siloName",
  37. align: "center",
  38. sorttype: "string",
  39. editable: false
  40. },
  41. {
  42. name: "FNAME",
  43. index: "FNAME",
  44. align: "center",
  45. sorttype: "int",
  46. editable: true,
  47. edittype: "select",
  48. editoptions:{
  49. dataUrl: "${contextPath }/admin/silomanage/fselect.html"
  50. }
  51. },
  52. {
  53. name: "ENABLE",
  54. index: "ENABLE",
  55. align: "center",
  56. sorttype: "string",
  57. editable: true,
  58. edittype: "select",
  59. editoptions: {value:{"Yes":"是","No":"否"}}
  60. }
  61. ],
  62. caption: "精料仓管理", //标题
  63. cellEdit: true,
  64. cellsubmit: "clientArray", //当单元格发生变化后不直接发送请求、"remote"默认直接发送请求
  65. afterSaveCell: function(rowid,name,val,iRow,iCol) {
  66. var rowData = $("#list").jqGrid("getRowData",rowid);
  67. $.ajax({
  68. async: false,
  69. type: 'POST',
  70. dataType:'json', //返回类型jsond
  71. data: "ID="+rowData.ID+"&colName="+name+"&colValue="+val,
  72. url: "${contextPath }/admin/silomanage/siloupdate.html",
  73. error: function(){alert("系统错误");},
  74. success: function(json){
  75. }
  76. });
  77. },
  78. pager: "#page", //#page分页控件绑定的位置对象
  79. pginput: false, //不显示分页文本框
  80. pgbuttons: false, //不显示翻页按钮
  81. rownumbers: true, //是否显示行数
  82. autowidth: true //自动调节宽度
  83. });
  84. //获取数据集
  85. mydata = getLists();
  86. if(mydata!=null){
  87. for(var i=0;i<=mydata.length;i++){
  88. jQuery("#list").jqGrid('addRowData',i+1,mydata[i]);
  89. }
  90. jQuery("#list").jqGrid().trigger("reloadGrid"); //添加完数据后客户端自动刷新一次、实现客户端数据与服务器数据的完全分离
  91. }
  92. //绑定、设置工具栏
  93. jQuery("#list").jqGrid("navGrid","#page",{
  94. add: true, addtext: "添加",
  95. edit: false, edittext: "编辑",
  96. del: true, deltext: "删除",refresh: false,
  97. addfunc: addRow, //自定义添加方法
  98. delfunc: deleteRow, //自定义删除方法
  99. searchtext: "搜索",
  100. refreshtext: "刷新",
  101. alerttext:"请选择一条记录!"
  102. });
  103. }
  104. //获取服务器数据
  105. function getLists(){
  106. $.ajax({
  107. async: false,
  108. type: 'POST',
  109. dataType:'json', //返回类型json
  110. url: "${contextPath }/admin/silomanage/silolist.html",
  111. error: function(){alert("系统错误");},
  112. success: function(json){
  113. mydata = json;
  114. }
  115. });
  116. return mydata;
  117. }
  118. </script>
  119. </head>
  120. <body style="background-color: #E0E0E0">
  121. <div>
  122. <div class="navfrm">
  123. <span>当前位置:</span>
  124. <span><a href="${contextPath }/admin/welcome.html">首页</a></span>
  125. <span>&nbsp;>>&nbsp;</span>
  126. <span>精料仓管理</span>
  127. </div>
  128. <table id="list"></table>
  129. <div id="page"></div>
  130. </div>
  131. </body>
  132. </html>