ExtJs grid批量处理

来源:互联网 发布:汽车门户网站源码 编辑:程序博客网 时间:2024/05/01 21:30

  1. <html>  
  2.     <head>  
  3.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
  4.         <title>JSP Page</title>  
  5.         <link rel="stylesheet" type="text/css" href="ExtJs/resources/css/ext-all.css" mce_href="ExtJs/resources/css/ext-all.css" />  
  6.         <link rel="stylesheet" type="text/css" href="jmaki-standard.css" mce_href="jmaki-standard.css" />  
  7.         <mce:script type="text/javascript" src="ExtJs/adapter/ext/ext-base.js" mce_src="ExtJs/adapter/ext/ext-base.js"></mce:script>  
  8.         <mce:script type="text/javascript" src="ExtJs/ext-all.js" mce_src="ExtJs/ext-all.js"></mce:script>  
  9.         <mce:script type="text/javascript"><!--  
  10.             var storeFatList;  
  11.             var cmFatList;  
  12.             var gridFatList;  
  13.             var sm = new Ext.grid.CheckboxSelectionModel();  
  14.             Ext.onReady(viewFatlist);  
  15.             function viewFatlist()  
  16.             {  
  17.                 if(storeFatList==null)  
  18.                 {  
  19.                     storeFatList = new Ext.data.Store({  
  20.                         proxy: new Ext.data.HttpProxy({  
  21.                             url: 'auditUsr.action'  
  22.                         }),  
  23.                         // create reader that reads the Topic records  
  24.                         reader: new Ext.data.JsonReader({  
  25.                             root: 'usrs',  
  26.                             totalProperty: 'totalCount',  
  27.                             successProperty :'success',  
  28.                             id: 'threadid',  
  29.                             fields: [  
  30.                                 {name: 'uid',mapping:'uid',type:'int'},  
  31.                                 {name: 'userName', mapping:'uname',type:'string'},  
  32.                                 {name: 'email', mapping:'email',type:'string'},  
  33.                                 {name: 'status',mapping:'state',type:'int'}  
  34.                             ]  
  35.                         })  
  36.                     });  
  37.                 }  
  38.                 // the column model has information about grid columns  
  39.                 // dataIndex maps the column to the specific data field in  
  40.                 // the data store  
  41.                 if(cmFatList==null)  
  42.                 {  
  43.                     cmFatList = new Ext.grid.ColumnModel([  
  44.                         sm,  
  45.                         {  
  46.                             header: "用户名",  
  47.                             dataIndex: 'uid'  
  48.                         },{  
  49.                             header: "姓名",  
  50.                             dataIndex: 'userName'  
  51.                         },{  
  52.                             header: "Email",  
  53.                             dataIndex: 'email'  
  54.                         },{  
  55.                             header: "状态",  
  56.                             dataIndex: 'status'  
  57.                         }]);  
  58.                     cmFatList.defaultSortable = true;  
  59.                 }  
  60.                 if(gridFatList==null)  
  61.                 {  
  62.                     gridFatList = new Ext.grid.GridPanel({  
  63.                         el:'noAuditUsers',  
  64.                         store: storeFatList,  
  65.                         frame:true,  
  66.                         width:685,  
  67.                         height:400,  
  68.                         title:'查询结果',  
  69.                         collapsible :true,  
  70.                         cm: cmFatList,  
  71.                         sm: sm,  
  72.                         trackMouseOver:false,  
  73.                         loadMask: false,  
  74.                         tbar: new Ext.PagingToolbar({  
  75.                             pageSize: 20,  
  76.                             store: storeFatList,  
  77.                             displayInfo: true,  
  78.                             cls: 'x-btn-text-icon details',  
  79.                             displayMsg: '显示的结果 {0} - {1} / {2}',  
  80.                             emptyMsg: "没有符合查询条件的记录"  
  81.                         })  
  82.                     });  
  83.                 }  
  84.                 gridFatList.render();gridFatList.collapse(true);  
  85.                 storeFatList.load({params:{start:0, limit:20}});  
  86.             }  
  87.             //返回被选择的行的UID  
  88.             function getFatSelectedIdArray()  
  89.             {  
  90.                 var record=gridFatList.getSelectionModel().getSelections();  
  91.                 if(record == null || record.length == 0)  
  92.                     return null;  
  93.                 var array = new Array(record.length);  
  94.                 for(var i=0;i<record.length;i++)  
  95.                 {  
  96.                     array[i] = record[i].get('uid');  
  97.                 }  
  98.                 return array;  
  99.             }  
  100.             //响应 用户成正式用户 按钮事件  
  101.             function setDueUser()  
  102.             {  
  103.                 array = getFatSelectedIdArray();  
  104.                 if(array == null)  
  105.                 {  
  106.                     alert('请选择用户然后再执行操作');  
  107.                     return;  
  108.                 }  
  109.                 var info = '';  
  110.                 for(var i=0;i<array.length;i++)  
  111.                 {  
  112.                     info += array[i] + ';';  
  113.                 }  
  114.                 var conn = new Ext.data.Connection();  
  115.                 // 发送异步请求  
  116.                 conn.request({  
  117.                     // 请求地址  
  118.                     url: 'executeAudit.action',  
  119.                     method: 'GET',  
  120.                     params:'uid=' + info,  
  121.                     // 指定回调函数  
  122.                     callback: callback  
  123.                 });  
  124.                 //回调函数  
  125.                 function callback(options, success, response){  
  126.                     if(success)  
  127.                     {  
  128.                         if(response.responseText.trim() == "1")  
  129.                         {  
  130.                             alert('审核成功');  
  131.                             storeFatList.reload();  
  132.                         }  
  133.                         else  
  134.                             alert('操作失败,请重试');  
  135.                     }  
  136.                     else  
  137.                         alert('连接超时,请重试');  
  138.                 }  
  139.             }  
  140.             function refreshData()  
  141.             {  
  142.                 setTimeout(function()  
  143.                 {  
  144.                     storeFatList.reload();  
  145.                 },1000);  
  146.             }  

原创粉丝点击