123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <%@ page contentType="text/html; charset=utf-8" session="false" %>
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
- <script type="text/javascript">
- var mydataP2,colName;
- $(document).ready( function() {
- loadNames(); //动态生成字段名称
- loadPlan2(); //加载jqgrid
- panelC = $("body").layout("panel","center").panel();
- panelSHeight = document.body.clientHeight - panelC.height();
- $("#p1list").jqGrid("setGridHeight",panelSHeight-130);
- $("#p2list").jqGrid("setGridHeight",panelSHeight-130);
- $("#p2list").jqGrid("setGridWidth",document.body.clientWidth*0.48);
- });
- $(window).resize(function(){
- $("#p2list").jqGrid("setGridWidth",document.body.clientWidth*0.48);
- });
-
- //jqgrid初始化
- function loadPlan2(){
- jQuery("#p2list").jqGrid({
- datatype: "local", //从服务器端返回的数据类型,(表格期望接收的数据类型)。可选类型:xml,xmlstring,json,local,function
- height: 150, //高度
- colNames: colName,
- colModel:[
- {
- name: "ID",
- index: "ID",
- width: 1,
- align: "center",
- sorttype: "string",
- hidden: true
- },
- {
- name: "SORT",
- index: "SORT",
- align: "center",
- sorttype: "string"
- },
- {
- name: "BNAME",
- index: "BNAME",
- align: "center",
- sorttype: "string"
- },
- {
- name: "LWEIGHT",
- index: "LWEIGHT",
- align: "center",
- sorttype:"number",
- editable: true
- }
- ],
-
- cellEdit: true,
- cellsubmit: "clientArray", //当单元格发生变化后不直接发送请求、"remote"默认直接发送请求
-
- afterSaveCell: function(rowid,name,val,iRow,iCol) {
- var rowData = $("#p2list").jqGrid("getRowData",rowid);
- var currentpId = $("#currentpId").val();
- $.ajax({
- async: false,
- type: 'POST',
- dataType:'json', //返回类型jsond
- data: "ID="+rowData.ID+"&colValue="+val+"¤tpId="+currentpId,
- url: "${contextPath }/admin/recipeplan/dateplan2updatedyg.html",
- error: function(){alert("系统错误");},
- success: function(json){
- }
- });
- },
-
- footerrow: true, //统计运算的功能
- gridComplete: completeMethod,
- autowidth: true //自动调节宽度
-
- });
-
- //获取数据集
- mydataP2 = getPlan2();
-
- if(mydataP2!=null){
- for(var i=0;i<=mydataP2.length;i++){
- jQuery("#p2list").jqGrid('addRowData',i+1,mydataP2[i]);
- }
- }
- }
-
- //获取服务器数据
- function getPlan2(){
- var currentpId = $("#currentpId").val();
- $.ajax({
- async: false,
- type: 'POST',
- dataType:'json', //返回类型json
- url: "${contextPath }/admin/recipeplan/plan2list.html?currentpId="+currentpId,
- error: function(){alert("系统错误");},
- success: function(json){
- mydataP2 = json;
- }
- });
- return mydataP2;
- }
- //页脚统计
- function completeMethod(){
- var sum_lweight=$("#p2list").getCol("LWEIGHT",false,"sum");
- $("#p2list").footerData("set", {SORT:"合计:", LWEIGHT: sum_lweight.toFixed(2)});
- }
-
- //动态生成字段名称
- function loadNames(){
- var lpplanType = $("#lpplanType").val();
- if(lpplanType == 1){
- //如果是上料车
- colName = ["主键","操作序号", "发料车次","发料重量"]; //列名
- }else{
- //如果是混合、发料车
- colName = ["主键","操作序号", "舍栏编号","设计重量"]; //列名
- }
- }
- </script>
- <table id="p2list"></table>
|