您的位置:首页 > 产品设计 > UI/UE

easyui formatter实现超链接效果

2016-06-12 11:57 417 查看
    formatter是格式化的意思,也就是以何种形式呈现的意思。项目中需要在easyui-datagrid的某一列做成超链接的效果,点击并能够出现一个弹出框;

    formatter该属性是一个函数,它包含两个参数: value: 对应字段的当前列的值,record: 当前行的记录数据。

页面代码: 

<span style="font-family:SimSun;font-size:18px;"><table id="dg" class="easyui-datagrid" style="width: 1000px"
data-options="
rownumbers:true,striped:true,loadMsg:'正在加载用户信息',singleSelect:true,method:'get',pagination:true,url:'/CadresRate/queryAllDocument',pageSize:20,pageList:[10,20,30,40,50],pageNumber:1,toolbar:toolbar">
<thead>
<tr style="width: 100%">

<th data-options="field:'DocumentName',width:180 ,<strong>formatter:FileUrl</strong>">文件名称</th>

</tr>
</thead>
</table></span>


JS代码:
<span style="font-family:SimSun;font-size:18px;"><script type="text/javascript">

    function FileUrl(value, rowData) {
        if (value == null || value == "") {
            return "<a href='javascript:void(0)'onclick=showImg('" + value + "');><a/>";
        } else {
            return "<a href='javascript:void(0)'onclick=showImg('" + value + "');>" + value + "<a/>";
        }
    }

</script></span>

注意事项
formatter函数不会作用在列属性checkbox为true的单元格上,checkbox列是组件预留的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: