---恢复内容开始---
1.年龄的属性:<t:dgCol title="年龄" extend="{style:'50px'}" formatterjs="formatAgeFun" style="query="true" width="120"></t:dgCol>
对应的js函数是:
function formatAgeFun(age,row,index){
var str="原:"+age+",现 :"+(Number(age)+20);
return str;
}
其中str是返回的值。
2.部门保存的时候保存的是部门id,前端显示的代码如下:
<t:dgCol title="部门" field="depId" query="true" queryMode="single" dictionary="t_s_depart,id,departname" width="120"></t:dgCol>
其中t_s_depart是表的名字,id是对应的id值,departname是要显示的部门名称。
3.性别的拓展颜色代码: <t:dgCol title="性别" field="sex" query="true" showMode="radio" dictionary="sex" width="120" extendParams="styler:fmtype"></t:dgCol>
对应的js函数是:
function fmtype(val,row,index){
//可添加更多CSS样式
var s1 = 'background-color:#f89406;color:#FFF;';
var s2 = 'background-color:#3a87ad;color:#FFF;';
var s3 = 'background-color:#21B9BB;';
if (val =='1') {
return s1
}
if (val =='0') {
return s2
}
return s3
}
val是性别的颜色,s1,s2,s3是返回的颜色值。
4.部门代码:<t:dgCol title="部门code" field="extField"></t:dgCol>
其中extField这个字段是拓展出来的,在controller层中的datagrid代码如下:
this.jeecgDemoService.getDataGridReturn(cq, true);
//String total_salary = String.valueOf(jeecgMinidaoDao.getSumSalary());
/*
* 说明:格式为 字段名:值(可选,不写该值时为分页数据的合计) 多个合计 以 , 分割
*/
//dataGrid.setFooter("salary:"+(total_salary.equalsIgnoreCase("null")?"0.0":total_salary)+",age,email:合计");
List<JeecgDemoEntity> list = dataGrid.getResults();
Map<String,Map<String,Object>> extMap = new HashMap<String, Map<String,Object>>();
for(JeecgDemoEntity temp:list){
//此为针对原来的行数据,拓展的新字段
Map m = new HashMap();
m.put("extField",this.jeecgMinidaoDao.getOrgCode(temp.getDepId()));
System.out.println(temp.getDepId());
System.out.println(this.jeecgMinidaoDao.getOrgCode(temp.getDepId())+"--------------");
extMap.put(temp.getId(), m);
}
//dataGrid.setFooter("extField,salary,age,name:合计");
dataGrid.setFooter("salary,age,name:合计");
TagUtil.datagrid(response, dataGrid, extMap);
在jeecgminidao的方法如下:
@Arguments("id")
@ResultType(String.class)
@Sql("SELECT org_code FROM t_s_depart where id=:id")
public java.lang.String getOrgCode(String id);
5.图片显示属性:
<t:dgCol title="头像" field="touxiang" queryMode="group" image="true" width="60"></t:dgCol>
6.文件显示属性:
<t:dgCol title="文件" field="testFile1" queryMode="single" downloadName="附件下载" width="120"></t:dgCol>
7.文件存储目录:
resuorce-------sysConfig.properties
8.弹出tab表单方法:
function addbytab(){
addOneTab("添加表单", "jeecgListDemoController.do?addWithbtn");
}
---恢复内容结束---