1. 程式人生 > >easyui datagrid 彈出視窗

easyui datagrid 彈出視窗

我的主頁面,程式碼如下:

Javascript程式碼  收藏程式碼
  1. //新增資料彈出視窗  
  2. $(function(){             
  3.     addDataWin = $('#addData-window').window({                    
  4.         href:'${basePath}/page/marketPlat2/addData/addData.jsp?workId=${workId}year=${year}&month=${month}   &quarter=${quarter}&businessType=${businessType}&type=${type}'
    ,  
  5.     title:'新增資料',  
  6.     left:'100px',  
  7.     top:'70px',  
  8.     closed: true,  
  9.     modal: false,  
  10.     cache: false,  
  11.     minimizable:false,  
  12.     maximizable:false,  
  13.     collapsible:false,  
  14.     shadow: false  
  15.     });  
  16. //新增資料彈出視窗  
  17.     function addData(){  
  18.         addDataWin.window('open');                       
  19.     }  
  20. }  
  21. //這裡只插入了一個datagrid的部分程式碼,就是點選這個按鈕,就會新呼叫addData()方法;  
  22. {  
  23.     id:'add',  
  24.     text:'新增',  
  25.     iconCls:'icon-add',  
  26.     handler:addData  
  27. }  
  28.  //關閉彈出視窗  
  29. function closeWin(myWin) {  
  30.     myWin.window('close');  
  31. };    
Html程式碼  收藏程式碼
  1. <!-- 彈出視窗:新增資料 -->  
  2. <div id="addData-window" title
    ="新增資料" style="width:510px;height:300px;font-size: 16">  
  3. </div>  


效果圖為: 
主頁面程式碼 

第一個彈出視窗程式碼為:

Html程式碼  收藏程式碼
  1. <%@ page language="java" contentType="text/html; charset=utf-8"  
  2.     pageEncoding="utf-8"%>  
  3. <%  
  4.     String path = request.getContextPath();  
  5.     String basePath = request.getScheme() + "://"  
  6.             + request.getServerName() + ":" + request.getServerPort()  
  7.             + path + "/";  
  8.     response.setHeader("Cache-Control", "no store");//HTTP 1.1   
  9.     response.setHeader("Pragma", "no store");//HTTP 1.0   
  10.     response.setDateHeader("Expires", 0);//在代理伺服器端防止緩衝  
  11.     request.setAttribute("workId", request.getParameter("workId"));//yearwork表中的  
  12.     request.setAttribute("year", request.getParameter("year"));//年  
  13.     request.setAttribute("month", request.getParameter("month"));//月  
  14.     request.setAttribute("querter", request.getParameter("quarter"));//季  
  15.     request.setAttribute("businessType", request.getParameter("businessType"));//任務型別      (周1 年3 季2 月0)  
  16.     request.setAttribute("type", request.getParameter("type"));  
  17. %>  
  18. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
  19. <html>  
  20. <head>  
  21. <base href="<%=basePath%>">  
  22. <title>新增資料</title>  
  23. <meta http-equiv="pragma" content="no-cache">  
  24. <meta http-equiv="cache-control" content="no-cache">  
  25. <meta http-equiv="expires" content="0">  
  26. <script type="text/javascript">  
  27.     $(function(){  
  28.         $('#btn-save,#btn-close-save,#serchCustomList,#seachProductList').linkbutton();  
  29.         customobjWin=$('#customobj-window').window({  
  30.             href:'${basePath}/page/marketPlat2/addData/seachCustomobj_list.jsp?',  
  31.             title:'選擇客戶單位',           
  32.             closed: true,  
  33.             minimizable:false,  
  34.             maximizable:false,    
  35.             collapsible:false,  
  36.             cache:false,  
  37.             shadow:false  
  38.         });  
  39.         productWin=$('#product-window').window({  
  40.             href:'${basePath}/page/marketPlat2/addData/seachProduct_list.jsp?&type=${type}',  
  41.             title:'選擇產品',             
  42.             closed: true,  
  43.             minimizable:false,  
  44.             collapsible:false,  
  45.             maximizable:false,    
  46.             cache:false,  
  47.             shadow:false  
  48.         });  
  49.     });  
  50.     //選擇客戶單位彈出視窗  
  51.     function seachCustomobj(){  
  52.         customobjWin.window('open');  
  53.     }  
  54.     //給客戶單位文字框和隱藏域賦值  
  55.     function setCustomobjName(customOBJ){  
  56.         $('#seachCustomobjId').val(customOBJ.customobjId);  
  57.         var s =$('#seachCustomobjId').val();  
  58.         $('#seachCustomobjName').val(customOBJ.customobjName);  
  59.     }  
  60.     //給產品文字框和隱藏域賦值  
  61.     function setProductName(productOBJ){  
  62.         $('#seachProductId').val(productOBJ.productId);  
  63.         $('#seachProductName').val(productOBJ.productName);  
  64.     }  
  65.     //關閉客戶單位彈出視窗  
  66.     function closeCustomWin(){  
  67.         customobjWin.window('close');  
  68.     }  
  69.     //關閉產品彈出視窗  
  70.     function closeProductWin(){  
  71.         productWin.window('close');  
  72.     }  
  73.     //選擇產品彈出視窗  
  74.     function seachProduct(){  
  75.         var customobjId = $('#seachCustomobjId').val();  
  76.         if(customobjId==""||customobjId==null){  
  77.             alert("請選擇客戶單位");  
  78.             return false;  
  79.         }else{  
  80.             productWin.window('open');  
  81.         }  
  82.     }  
  83. </script>  
  84. </head>  
  85. <body>  
  86.         <div style="padding: 10px 10px 10px 10px;">  
  87.                 <form method="poxt">  
  88.                     <table >  
  89.                         <tr>  
  90.                             <td width="30%">請選擇客戶單位:</td>  
  91.                             <td width="50%">  
  92.                                 <input type="hidden" id="seachCustomobjId" name="seachCustomobjId" />  
  93.                                 <input type="text" name="seachCustomobjName" id="seachCustomobjName" readonly="readonly"  class="easyui-validatebox"  required="true" missingMessage="請選擇客戶單位名稱" style="width:200px"></input>  
  94.                             <td>  
  95.                             <td width="20%"><a href="javascript:void(0)" onclick="seachCustomobj()"  id="serchCustomList" icon="icon-search">選擇</a></td>  
  96.                         </tr>  
  97.                         <tr><td colspan="3">&nbsp;</td></tr>  
  98.                         <tr>  
  99.                             <td>請選擇產品:</td>  
  100.                             <td>  
  101.                                 <input type="hidden" id="seachProductId" name="seachProductId" />  
  102.                                 <input type="text" name="seachProductName" id="seachProductName" readonly="readonly"  class="easyui-validatebox"  required="true" missingMessage="請選擇產品名稱" style="width:200px"></input>  
  103.                             <td>  
  104.                             <td ><a href="javascript:void(0)" onclick="seachProduct()" id="seachProductList" icon="icon-search">選擇</a></td>  
  105.                         </tr>  
  106.                     </table>  
  107.                 </form>  
  108.             </div>  
  109.             <div style="text-align: center; padding: 5px;">  
  110.                 <a href="javascript:void(0)" onclick="saveAddData()" id="btn-save" icon="icon-save">儲存</a>&nbsp;&nbsp;&nbsp;&nbsp;  
  111.                 <a href="javascript:void(0)" onclick="closeWin(addDataWin)" id="btn-close-save" icon="icon-cancel">取消</a>  
  112.             </div>  
  113.     </table>  
  114.     <!-- 2期新增資料功能之選擇客戶單位彈出視窗 -->  
  115.         <div id="customobj-window" class="earyui-window" title="選擇客戶單位" style="width: 550px; height: 350px; padding: 0px; background:#fafafa; ">  
  116.     <!-- 2期新增資料功能之選擇產口彈出視窗 -->  
  117.         <div id="product-window" class="earyui-window" title=