easyUI datagrid显示图片的问题

飞舞的锄头 2014-02-20 03:01:42
数据库中存放的是图片的路径(shos_pic),该怎么显示在easyui 表格中呢?

<table id="d_day_pTOP" class="easyui-datagrid" style="width:auto;height:auto" title="Daily_Sales_TopShoes"
pagination='true' data-options=" pagination:true, url: 'get_top20product.php', singleSelect: true, rownumbers:true "
>
<thead>
<tr>
<th field="classname8" width="80" ><strong>SEASON</strong></th>
<th field="colthno" width="120" ><strong>PRODUCT CODE</strong></th>
<th field="shoes_picture" width="120" ><strong>SHOES_PIC</strong></th>
<!-- http://www.jkjyfashion.com/photo/collection/1376897034.jpg'> -->
<th field="nos_nb" width="120" ><strong>TRANSACTION</strong></th>
<th field="nb" width="120" ><strong>QUANTITY</strong></th>
<th field="amt" width="120" ><strong>SALES(VAT)</strong></th>
<th field="amt_per" width="120" ><strong>% OF TOTAL</strong></th>
</tr>
</thead>
</table>
...全文
3279 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
飞舞的锄头 2014-02-20
  • 打赏
  • 举报
回复
引用 5 楼 u012463264 的回复:
还可以取到row呢 取哪个列都行啊
<th field="shoes_picture" width="120" ><strong>SHOES_PIC</strong></th>
这对应的是一列(里面是图片的路径),现在我要把路径换成图片具体该怎么写?
飞舞的锄头 2014-02-20
  • 打赏
  • 举报
回复
引用 3 楼 showbo 的回复:
楼主去认真看下api,formatter就是格式化数据为你需要的显示各使用的 http://www.jeasyui.com/documentation/index.php
没看太明白,请问这个formatter能获取单元格的值,现在我面临的问题是,这单元格中原本显示的是图片的路径,现在要把路径换成图片,该怎么写?
Go 旅城通票 2014-02-20
  • 打赏
  • 举报
回复
$('#dg').datagrid({ columns:[[ {field:'userId',title:'User', width:80, formatter: function(value,row,index){ if (row.user){ return row.user.name; } else { return value; } } } ]] }); value为当前此列的值,row为当前此行的值,index为数据行所在集合的下标
别闹腰不好 2014-02-20
  • 打赏
  • 举报
回复
还可以取到row呢 取哪个列都行啊
别闹腰不好 2014-02-20
  • 打赏
  • 举报
回复
比如这列是图片的地址,要显示图片 , <th data-options="field:'shoes_picture',formatter:showImg"width="120" ><strong>SHOES_PIC</strong></th> JS:  function showImg(val,row){ return '<img src='+val+'/>'; }
Go 旅城通票 2014-02-20
  • 打赏
  • 举报
回复
楼主去认真看下api,formatter就是格式化数据为你需要的显示各使用的 http://www.jeasyui.com/documentation/index.php
飞舞的锄头 2014-02-20
  • 打赏
  • 举报
回复
引用 1 楼 showbo 的回复:
<th field="shoes_picture" width="120" data-options="formatter:function(v){return '<img src='+v+'/>'}"><strong>SHOES_PIC</strong></th>

这个‘V’是图片路径吧,可‘V’就是这一列对应的值啊,该怎么调用呢?
Go 旅城通票 2014-02-20
  • 打赏
  • 举报
回复
<th field="shoes_picture" width="120" data-options="formatter:function(v){return '<img src='+v+'/>'}"><strong>SHOES_PIC</strong></th>

87,922

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧