123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <%@ page contentType="text/html; charset=utf-8" session="false" %>
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
- <head>
- <title>我的工作台</title>
- <%@ include file="../common/header.jsp" %>
- <script type="text/javascript">
- var mydata,operType;
- $(document).ready( function() {
- loadList(); //加载jqgrid
- $("#list").jqGrid("setGridHeight",$(window).height() - 105);
- $("#list").jqGrid("setGridWidth",document.body.clientWidth - 5);
- });
- $(window).resize(function(){
- $("#list").jqGrid("setGridHeight",$(window).height() - 105);
- $("#list").jqGrid("setGridWidth",document.body.clientWidth - 5);
- });
-
- //jqgrid初始化
- function loadList(){
- jQuery("#list").jqGrid({
- datatype: "local", //从服务器端返回的数据类型,(表格期望接收的数据类型)。可选类型:xml,xmlstring,json,local,function
- height: "70%", //高度
- colNames:["主键","精料仓名称","饲料","是否启用"], //列名
- colModel:[
- {
- name: "ID",
- index: "ID",
- align: "center",
- sorttype: "string",
- editable: true,
- hidden: true
- //editoptions:{readonly:true} 如果要显示该列可以设置只读
- },
- {
- name: "siloName",
- index: "siloName",
- align: "center",
- sorttype: "string",
- editable: false
- },
- {
- name: "FNAME",
- index: "FNAME",
- align: "center",
- sorttype: "int",
- editable: true,
- edittype: "select",
- editoptions:{
- dataUrl: "${contextPath }/admin/silomanage/fselect.html"
- }
- },
- {
- name: "ENABLE",
- index: "ENABLE",
- align: "center",
- sorttype: "string",
- editable: true,
- edittype: "select",
- editoptions: {value:{"Yes":"是","No":"否"}}
- }
- ],
- caption: "精料仓管理", //标题
-
- cellEdit: true,
- cellsubmit: "clientArray", //当单元格发生变化后不直接发送请求、"remote"默认直接发送请求
-
-
- afterSaveCell: function(rowid,name,val,iRow,iCol) {
- var rowData = $("#list").jqGrid("getRowData",rowid);
- $.ajax({
- async: false,
- type: 'POST',
- dataType:'json', //返回类型jsond
- data: "ID="+rowData.ID+"&colName="+name+"&colValue="+val,
- url: "${contextPath }/admin/silomanage/siloupdate.html",
- error: function(){alert("系统错误");},
- success: function(json){
- }
- });
- },
-
- pager: "#page", //#page分页控件绑定的位置对象
- pginput: false, //不显示分页文本框
- pgbuttons: false, //不显示翻页按钮
- rownumbers: true, //是否显示行数
- autowidth: true //自动调节宽度
- });
-
- //获取数据集
- mydata = getLists();
-
- if(mydata!=null){
- for(var i=0;i<=mydata.length;i++){
- jQuery("#list").jqGrid('addRowData',i+1,mydata[i]);
- }
- jQuery("#list").jqGrid().trigger("reloadGrid"); //添加完数据后客户端自动刷新一次、实现客户端数据与服务器数据的完全分离
- }
- //绑定、设置工具栏
- jQuery("#list").jqGrid("navGrid","#page",{
- add: true, addtext: "添加",
- edit: false, edittext: "编辑",
- del: true, deltext: "删除",refresh: false,
- addfunc: addRow, //自定义添加方法
- delfunc: deleteRow, //自定义删除方法
- searchtext: "搜索",
- refreshtext: "刷新",
- alerttext:"请选择一条记录!"
- });
-
- }
-
- //获取服务器数据
- function getLists(){
- $.ajax({
- async: false,
- type: 'POST',
- dataType:'json', //返回类型json
- url: "${contextPath }/admin/silomanage/silolist.html",
- error: function(){alert("系统错误");},
- success: function(json){
- mydata = json;
- }
- });
- return mydata;
- }
- </script>
- </head>
- <body style="background-color: #E0E0E0">
- <div>
- <div class="navfrm">
- <span>当前位置:</span>
- <span><a href="${contextPath }/admin/welcome.html">首页</a></span>
- <span> >> </span>
- <span>精料仓管理</span>
- </div>
- <table id="list"></table>
- <div id="page"></div>
- </div>
- </body>
- </html>
|