EasyUI中datagrid表格验证数据为空且加tip提示

在项目中,表格数据如果为空会显示空白,会缺乏视觉感。
因此想用–字符填充
在这里插入图片描述
在表格中首先要验证数据为空的状态,封装一个判断为空的函数

function subSpace(str) {
    if (str == "" || str == "null" || str == null || str == undefined || str == "undefined") {
        return true
    } else {
        return false
    }
}

然后就是在表格中如何显示呢

columns: [[
            {field: 'beginTime', title: '开始时间', width: '14%', align: 'center',formatter:formatterIsNull},
            {field: 'endTime', title: '结束时间', width: '14%', align: 'center',formatter:formatterIsNull}
        ]],

其中在formatter中formatterIsNull函数来进行判断显示情况

//判断datagrid是否为空--显示,超长溢出tip提示
function formatterIsNull(val) {
    if (subSpace(val)) {
        return '—';
    }else{
        return "<div style='width: 100%;height:30px;margin:0;line-height:30px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;' title='" + val + "'>" + val + "</div>"
    }
}

这样就实现了对表格完美的实现。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值