jQuery EasyUI datagrid 无记录时,增加“暂无数据“提示

10 篇文章 0 订阅
2 篇文章 0 订阅
1、在onLoadSuccess中添加如下代码:
if (data.total == 0) {
                var body = $(this).data().datagrid.dc.body2;
                body.find('table tbody').append('<tr><td width="' + body.width() + '" style="height: 35px; text-align: center;"><h5>暂无数据</h5></td></tr>');
            }

完整代码:

$('#tt').datagrid({
        url: null,
        pagination: true,
        pageNumber: 1,
        pageList: [15, 20, 50],
        rownumbers: true,
        fitColumns: false,
        singleSelect: true,
        columns: [[
            { field: 'Q_CODE', title: '指标编码', width: 100, align: 'left', halign: 'center' },
            { field: 'Q_NAME', title: '指标名称', width: 250, align: 'left', halign: 'center' },
            { field: 'REASON', title: '不启用理由', width: 250, align: 'left', halign: 'center' },
            {
                field: 'STATE', title: '审核状态', width: 80, align: 'left', halign: 'center', hidden: false,
                formatter: function (value, row, index) {
                    if (value == 0) return "待处理";
                    else if (value == 1) return "待审核";
                    else if (value == 2) return "已通过";
                    else if (value == 3) return "已驳回";
                }
            },
            { field: 'REJECT', title: '驳回说明', width: 250, align: 'left', halign: 'center' },
            {
                field: 'ID', title: '操作', width: 240, align: 'center', halign: 'center', hidden: false,
                formatter: function (value, row, index) {
                    var state = row.STATE;
                    if (state == 1) {
                        return '<a href="javascript:void(0);" οnclick="AuditFileConfig(\'' + row.ID + '\',\'' + " " + '\');">查看</a>' + '&nbsp;&nbsp;' + ' <a  href="javascript:void(0);"  οnclick="adopt(\'' + value + '\',\'' + row.Q_CODE + '\')">通过</a> ' + '&nbsp;&nbsp;' + ' <a  href="javascript:void(0);"  οnclick="rejectData(\'' + value + '\')">驳回</a>';
                    }
                    else {
                        return '<a href="javascript:void(0);" οnclick="AuditFileConfig(\'' + row.ID + '\',\'' + "" + '\')">查看</a>';
                    }
                }
            },
        ]],
        toolbar: '#tb',
        doPagination: function (pPageIndex, pPageSize) {
            Query(pPageIndex);
        },
        onLoadSuccess: function (data) {
            if (data.total == 0) {
                //$(this).data().datagrid.dc.body2 获取的是 DataGrid 组件的底层容器节点,body.width() 获取的是该容器的宽度值。不是在某个特定节点上调用 width() 方法
                var body = $(this).data().datagrid.dc.body2;
                body.find('table tbody').append('<tr><td width="' + body.width() + '" style="height: 35px; text-align: center;"><h5>暂无数据</h5></td></tr>');
            }
        }
    });

如下图所示:
在这里插入图片描述

2、设置emptyMsg 属性,emptyMsg 属性是 EasyUI 的 DataGrid 组件从版本 1.5.4 开始引入的。这个属性用于设置在 DataGrid 没有数据时显示的提示信息。
  emptyMsg: '<h4>暂无数据</h4>',  // 设置暂无数据的提示信息
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值