//扩展easyuidatagrid无数据时显示界面
var emptyView = $.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');
if (opts.rownumbers) {
vc.children('div.datagrid-view1').css('display', 'block');
}
if (opts.showFooter) {
vc.children('div.datagrid-view2').children('div.datagrid-footer').css('display', 'block');
}
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);
vc.children('div.datagrid-view1').css('display', 'none');
vc.children('div.datagrid-view2').children('div.datagrid-footer').css('display', 'none');
}
}
});
初始化datagrid时,加上
view:emptyView,
emptyMsg:"暂无相关数据",
即可