EasyUI 显示表单数据 小记
界面图:
1 /// <reference path="../jquery-1.4.1-vsdoc.js" /> 2 var chestList = new Object; 3 (function (log) { 4 5 log.init = function () { 6 var qParams = {'chestTypeStr':'0','chestName':'','receiveTypeStr':'0','sendStatusStr':'2','beginDateStr':'', 'endDateStr': '' 7 ,'createDateStr':''};//获取查询参数 8 var oldRowIndex; 9 var opt = $('#tbgridview'); 10 opt.datagrid({ 11 width: function(){ 12 if(document.body.clientWidth<800) 13 { 14 return 900; 15 }else{ 16 return "auto"; 17 }}(), //自动宽度 18 height: "auto", //固定高度 19 nowrap: false, 20 striped: true, //列背景切换 21 fitColumns: true, //自动适应列宽度 22 // singleSelect: true, //单选列 23 queryParams: qParams, //参数 24 url: '功能URL', //action地址 25 idField: 'pkid', //主索引 26 //frozenColumns: [[{ field: 'ck', checkbox: true}]], //是否显示复选框 27 pageList: [20, 30, 50], //每页现在行数 28 pagination: true, //是否开启分页 29 rownumbers: true, //是否显示行数 30 columns: [[ 31 {field: 'pkid', title: '宝箱任务ID', width: 40, align: 'left',hidden:"true" }, 32 {field:'ReceiveType',title:'领取方式ID',width:40,align:'left',hidden:"true"}, 33 { field: 'ChestType', title: '礼包类型', width: 100, align: 'left', 34 formatter: function (value, rowData, rowIndex) { 35 return (value==1?'登录宝箱':"会员宝箱"); 36 } },//(1登录宝箱,2会员宝箱) 37 { field: 'ChestName', title: '礼包名称', width: 100, align: 'left' }, 38 { field: 'TypeName', title: '领取方式', width: 100, align: 'left' }, 39 { field: 'beginDate', title: '开始时间', width: 100, align: 'left', 40 formatter:function(value,row,index){ 41 return FormatDate(value); 42 } }, 43 { field: 'endDate', title: '结束时间', width: 100, align: 'left', 44 formatter:function(value,row,index){ 45 return FormatDate(value); 46 } }, 47 { field: 'CreateDate', title: '创建时间', width: 100, align: 'left' , 48 formatter:function(value,row,index){ 49 return FormatDate(value); 50 } }, 51 { field: 'ChestStatus', title: '状态', width: 35, align: 'left', 52 formatter: function (value, rowData, rowIndex) { 53 return (value==0?'未发布':"发布"); 54 } }, 55 { field: 'ss', title: '操作', align: 'center', width: 70, 56 //添加超级链 57 formatter: function (value, rowData, rowIndex) { 58 //function里面的三个参数代表当前字段值,当前行数据对象,行号(行号从0开始) 59 var str = ""; 60 //未发布 61 if( rowData.ChestStatus == "0"){ 62 str +=' <a href="javascript: void(0);" onclick="chestList.setPublic(' + rowData.pkid + ', 1 );" style="color:blue; ">发布</a>'; 63 } 64 //发布 65 if( rowData.ChestStatus == "1"){ 66 str +=' <a href="javascript: void(0);" onclick="chestList.setPublic( ' + rowData.pkid + ',0 );" style="color:blue; ">取消发布</a>'; 67 } 68 //删除 69 if( rowData.ChestStatus == "2"){ 70 71 } 72 //encodeURIComponent 中文转码 73 str += ' <a href="javascript: void(0);" onclick="chestList.show('+rowData.pkid+',\'' + encodeURIComponent(rowData.ChestName) + '\','+rowData.ReceiveType+','+rowData.ChestType+',\'' + encodeURIComponent(rowData.TypeName) + '\');" style="color:green;">查看</a>'; 74 return str; 75 } 76 } 77 ]] 78 }).datagrid("getPager").pagination({ //底部工具条 79 buttons: [], 80 onBeforeRefresh: function () { 81 return true; 82 } 83 }); 84 85 //查询触发函数 86 log.Query= function () { 87 var chestType = $('#select_chest_type option:selected').val(); 88 var chestName = $('#txt_chestName').val(); 89 var gettype = $('#select_getType option:selected').val(); 90 var status = $('#select_status option:selected').val(); 91 var begindate = $('#txt_begindate').val(); 92 var enddate = $('#txt_enddate').val(); 93 var createdate = $('#txt_createdate').val(); 94 //参数 95 qParams = {'chestTypeStr':chestType, 96 'chestName':chestName, 97 'receiveTypeStr':gettype, 98 'sendStatusStr':status, 99 'beginDateStr':begindate, 100 'endDateStr': enddate, 101 'createDateStr':createdate 102 };//获取查询参数 103 104 var dg = jQuery('#tbgridview');//绑定数据 tableID:#tbgridview 105 dg.datagrid('options').queryParams = qParams; 106 dg.datagrid('options').pageNumber = 1; 107 var p = dg.datagrid('getPager'); 108 if (p) { 109 jQuery(p).pagination({ pageNumber: 1 }); 110 } 111 dg.datagrid('reload'); 112 return false; 113 } 114 115 //修改发布状态 116 log.setPublic=function(id,s){ 117 $.post('功能URL', {'id':id , 's': s }, function (result) { 118 $.jBox.tip(result.Message,'info'); 119 if(result.Status == "300"){ 120 window.top.location.href = '/Login/Login'; 121 return; 122 } 123 if(result.Status==200){ 124 var dg = jQuery('#tbgridview'); 125 var p = dg.datagrid('getPager'); 126 dg.datagrid('reload'); 127 } 128 }, 'json'); 129 } 130 //查看合成详细信息 131 log.show=function(id,chestname,gettype,chesttype,gettypename){ 132 133 document.location="URL?id="+id+"&chestType="+chesttype+"&chestName="+chestname+"&getType="+gettype+"&getTypeName="+gettypename; 134 } 135 } 136 })(chestList); 137 138 $(function () { 139 chestList.init(); 140 }); 141 142 143 144 145 146
漫漫人生,唯有激流勇进,不畏艰险,奋力拼搏,方能中流击水,抵达光明的彼岸