easyui datagrid无数据时显示相关提示内容
程序员文章站
2022-06-07 19:35:01
...
var myview = $.extend({},$.fn.datagrid.defaults.view,{
onAfterRender:function(target){
$.fn.datagrid.defaults.view.onAfterRender.call(this,target);
var opts = $(target).datagrid('options');
var vc = $(target).datagrid('getPanel').children('div.datagrid-view');
vc.children('div.datagrid-empty').remove();
if (!$(target).datagrid('getRows').length){
var d = $('<div class="datagrid-empty"></div>').html(opts.emptyMsg || 'no records').appendTo(vc);
d.css({
position:'absolute',
left:0,
top:50,
width:'100%',
textAlign:'center',
color:'red'
});
}
}
});
$('#dg').datagrid({
view: myview,
emptyMsg: 'no records found'
});
转载于:https://my.oschina.net/u/2925671/blog/1438887