关注JEECG发展历程 关注最新动态和版本, 记录JEECG成长点滴 更新日志 - 技术支持 - 招聘英才

JEECG最新版本下载 JEECG智能开发平台 - 显著提高开发效率 常见问题 - 入门视频 - 参与开源团队

商务QQ: 69893005、3102411850 商务热线(5*8小时): 010-64808099 官方邮箱: jeecgos@163.com

查看: 10239|回复: 3

为list页面添加附件下载和图片大小自定义标签

[复制链接]
发表于 2013-9-17 11:44:50 | 显示全部楼层 |阅读模式
第一步:easyui.tld
在easyui.tld中搜索<name>dgCol</name>,在结尾添加
  1.                 <attribute>
  2.                         <name>imageDiy</name>
  3.                         <rtexprvalue>true</rtexprvalue>
  4.                         <description>自定义图片大小字段(格式:width,height)</description>
  5.                 </attribute>
  6.                 <attribute>
  7.                         <name>download</name>
  8.                         <rtexprvalue>true</rtexprvalue>
  9.                         <description>附件下载(true,false)</description>
  10.                 </attribute>
复制代码
第二步:org.jeecgframework.tag.core.easyui.DataGridColumnTag
在org.jeecgframework.tag.core.easyui.DataGridColumnTag中添加
  1. protected String imageDiy;
  2. protected boolean download;

  3. public void setDownload(boolean download) {
  4.         this.download = download;
  5. }
  6. public void setImageDiy(String imageDiy) {
  7.         this.imageDiy = imageDiy;
  8. }
复制代码
在结尾doEndTag()方法的parent.setColumn中结尾添加  ,imageDiy,download

第三步:org.jeecgframework.tag.core.easyui.DataGridTag
在org.jeecgframework.tag.core.easyui.DataGridTag的setColumn方法中添加 , String imageDiy,boolean download(和之前doEndTag()中的位置不能变)
下面再添加dateGridColumn.setImageDiy(imageDiy);和dateGridColumn.setDownload(download);
最后在getField(StringBuffer sb, int frozen)方法下if (column.isImage())下添加
  1.                                 // 自定义显示图片
  2.                                 if (column.getImageDiy() != null) {
  3.                                         String[] tld = column.getImageDiy().split(",");
  4.                                         sb.append(",formatter:function(value,rec,index){");
  5.                                         sb.append(" return '<img width="" + tld[0]
  6.                                                         + "" height="" + tld[1]
  7.                                                         + "" border="0" src="'+value+'"/>'}");
  8.                                         tld = null;
  9.                                 }
  10.                                 if (column.isDownload()) {
  11.                                         sb.append(",formatter:function(value,rec,index){");
  12.                                         sb.append(" return '<a target="_blank" href="'+value+'">点击下载</a>'}");
  13.                                 }
复制代码
大功告成!





 楼主| 发表于 2013-9-17 11:47:25 | 显示全部楼层
使用方法:<t:dgCol imageDiy="90,50" title="XXX" field="XXX"></t:dgCol>90是宽,50是高,可自定义

<t:dgCol title="XXX" field="XXX" download="true"></t:dgCol>简单的附件下载,可扩展
发表于 2013-9-17 17:05:33 | 显示全部楼层
本帖最后由 GIN 于 2013-9-17 17:40 编辑

imageSize
发表于 2021-4-10 23:41:55 | 显示全部楼层
为什么提示我没有isDownload()这个方法?
QQ图片20210410234101.png
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表