①easyui 当鼠标悬停显示单元格信息:
$(this).datagrid('doCellTip',{'max-width':'600px','delay':300});
②jquery 获取checkbox多个被选元素
1 var swa = new Array(); 2 $("input[name='mainten.softwareReason']:checked").each(function(){ 3 swa.push($(this).val()); 4 }); 5 var softwareReason = swa.join(' '); 6 7 $.ajax({ 8 type: "post", 9 url: "json/FaultMainten_update.action", 10 data: { 11 id: $("#id").val(), 12 maintainerTel: $("#maintainerTel").val(), 13 softwareReason softwareReason, 14 repairData: $("#repairData").combobox("getValue"), 15 }, 16 success: function(data){ 17 var result = JSON.parse(data) 18 } 19 });
③提交进行修改update
function newsUpdate() { $('#updateFaultMainten').form('submit', { url : "json/FaultMainten_update.action", onSubmit : function() { return $("#updateFaultMainten").form('validate'); }, success : function(data) { parent.layer.msg('修改成功'); parent.$("#MsgListDiv").datagrid("reload"); closeLayer(); } }); }
④layer调用方法打开一个页面(jsp传jsp中文乱码解决)
function addFM() { var row = $("#MsgListDiv").datagrid("getSelected"); if (row) { var pid = row.pid; var pname = row.pname; layer.open({ type : 2, title : '添加故障维护信息', shadeClose : false, shade : 0.3, shift : 5, maxmin : true, area : [ '980px', '450px' ], content : 'admin/FaultMainten/FaultMainten_add.jsp?pid=' + pid + '&pname=' + encodeURIComponent(pname) }); layer.full(index); }else{ $.messager.alert("警告", "请选中一条记录", "warning"); } }
⑤easyui将单元格中文字规定长度,超出部分用"..."代替
$("#mytable2 tr td").each(function(i){ if($(this).text().length>15){ $(this).attr("title",$(this).text()); var text = $(this).text().substring(0,14)+'...'; $(this).text(text); } });
⑥action方法中
Ⅰ定义json:Map<String,Object> json=new HashMap<String,Object>(); Ⅱ定义需要传递的参数: HashMap<String,Object> params=new HashMap<String,Object>(); Ⅲ将params参数传递给service层,查询到list(假设)放入json中: json.put("rows",list);json中rows为系统定义放置行数据的键名 json.put("total",total);json中total为系统定义放置行分页计数的键名
⑦分页和不分页查询
//Ⅰ不分页查询 public List<PointFault> query(Map<String, Object> map){ SqlSessionTemplate sqlSession = new SqlSessionTemplate (sqlSessionFactory); List<PointFault> list = sqlSession.selectList ("com.shibo.trace.dao.PointFaultDao.query",map); return list; } /** * 不分页查询(上面调用的ssqlSession.selectList()) * @param queryid * @param params * @return */ public List selectList(String queryid,Map<String, Object> params){ return session.selectList(queryid, params); }
//Ⅱ分页查询 public List<PointFault> query(Map<String, Object> map,int page,int rows){ SqlSessionTemplate sqlSession = new SqlSessionTemplate (sqlSessionFactory); pageDaoUtil.setSession(sqlSession); List<PointFault> temp=pageDaoUtil.selectList ("com.shibo.trace.dao.PointFaultDao.query", map,new RowBounds((page-1) *rows,rows)); return temp; } /** * 分页查询(上面调用的pageDaoUtil.selectList()) * @param queryid 查询的id, * @param params 参数 * @param bounds 分页数据 如:new RowBounds((start-1)*Conv.pageSize, limit) * @return list */ public List selectList(String queryid,Map<String, Object> params,RowBounds bounds){ return session.selectList(queryid, params,bounds); }
⑧左连接(每一个left join与其它left join没有一点关系,一切只看它的ON子句的条件)
1 select pf.*,sm.bodystyle from POFA pf left join DEPO dp on pf.pid=dp.pid 2 left join SHMA sm on sm.smid=dp.smid left join PUB p on pf.region=p.admincode 3 where sm.pid='11111'