码迷,mamicode.com
首页 > 其他好文 > 详细

easyui —— footer

时间:2017-04-17 17:24:24      阅读:358      评论:0      收藏:0      [点我收藏+]

标签:span   名称   user   ted   ash   ble   方法   padding   height   

前言:

使用easyui的datagrid,在最后一行加上“总计”字样,效果如下:

技术分享

过程:

...
<table id="dg" title="xx管理" fitColumns="true" pagination="true" rownumbers="true" nowrap="true"
        fit="true" toolbar="#tb" data-options="pageSize:25,pageList:[10,15,25,50,100],singleSelect:true,showFooter: true">
    <thead>
    <tr id="options">
        <th data-options="field:‘id‘,width:50,align:‘center‘">编号</th>
        <th data-options="field:‘name‘,width:150,align:‘center‘">名称</th>
        <th data-options="field:‘remark‘,width:100,align:‘center‘">备注</th>
        <th data-options="field:‘addr‘,width:130,align:‘center‘">地区</th>
        <th data-options="field:‘percount‘,width:50,align:‘center‘,sortable:true">人数</th>
        <th data-options="field:‘chatCount‘,width:50,align:‘center‘">聊天条数</th>
        <th data-options="field:‘createtime‘,width:100,align:‘center‘,formatter:formatReg">创建时间</th>
        <th field="operate" width="120" align="center" data-options="formatter:formatOperate" >操作</th>
    </tr>
    </thead>
</table>
...

在data-option中增加showFooter属性为true,并在后台准备数据的时候增加footer属性,并且其中字段名跟数据库中的保持一致:

...
 return this.json({total: result.count, rows: result.data,footer:[{"name":"总计","percount":personTotal,"chatCount":chatTotal}]});
...

但是,莫名其妙的出现了下面的情景:

技术分享

就是在最后一栏“操作”中出现了不该出现的三个按钮,解决方法:在后台组织返回数据的时候,增加一个属性,比如:

...
 return this.json({total: result.count, rows: result.data,footer:[{"isFooter":true,"name":"总计","percount":personTotal,"chatCount":chatTotal}]});
...

然后在前台代码上增加一个判断:

...
 function formatOperate(value, row, index){
        var update = ‘<a  onclick="openUpdateDialog(‘+index+‘)" href="javascript:void(0)" title="修改" class="linkbutton" data-options="plain:true,iconCls:\‘icon-page_edit\‘"></a>‘;
        var delStr=‘<a  onclick="del(‘+row.id+‘)" href="javascript:void(0)" title="删除" class="linkbutton" data-options="plain:true,iconCls:\‘icon-delete\‘"></a>‘;
        var checkUsers =‘<a onclick="checkUsers(‘+index+‘)" href="javascript:void(0)" title="查看圈子成员" class="linkbutton" data-options="plain:true,iconCls:\‘icon-group\‘"></a>‘;
        if(!row.isFooter){
            return checkUsers+ "&nbsp;"+update+ "&nbsp;"+delStr;
        }else{
            return "";
        }
    }
...

后言:

这样便完美的解决了footer中出现的问题。

easyui —— footer

标签:span   名称   user   ted   ash   ble   方法   padding   height   

原文地址:http://www.cnblogs.com/zhengyeye/p/6723757.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!