扩展grid的onAfterRender事件
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("暂无记录").appendTo(vc);
d.css({
marginTop: 28,
'100%',
textAlign: 'center',
fontSize: 14
});
vc.css({
minHeight: 50
});
}
}
});
应用:
//使用
$('#dgReason').datagrid({
580,
view: myview,
columns: [
[
{ field: 'firstReason', title: '一级原因', 200, align: 'center' },
{ field: 'secondReason', title: '二级原因', 250 },
{ field: 'lockDays', title: '锁定天数', 100, align: 'center' },
{ field: 'code', hidden: true }
]
],
rownumbers: true,
loadMsg: "数据加载中...."
});