$(
function () {
$('#dg'
).datagrid({
fitColumns: true,
url: 'product.json'
,
pagination: true,
pageSize: 3
,
onLoadSuccess: function (data) {
if (data.total == 0
) {
//添加一个新数据行,第一列的值为你需要的提示信息,然后将其他列合并到第一列来,注意修改colspan参数为你columns配置的总列数
$(
this).datagrid('appendRow', { itemid: '<div style="text-align:center;color:red">没有相关记录!</div>' }).datagrid('mergeCells', { index: 0, field: 'itemid', colspan: 4
})
//隐藏分页导航条,这个需要熟悉datagrid的html结构,直接用jquery操作DOM对象,easyui datagrid没有提供相关方法隐藏导航条
$(
this).closest('div.datagrid-wrap').find('div.datagrid-pager'
).hide();
}
//如果通过调用reload方法重新加载数据有数据时显示出分页导航容器
else $(
this).closest('div.datagrid-wrap').find('div.datagrid-pager'
).show();
},
title: 'easyui datagrid没有数据显示无数据提示信息'
,
width: 550
,
columns: [[{ field: 'itemid', width: 80, title: 'Item ID'
},
{ field: 'productname', width: 100, editor: 'text', title: 'Product Name'
},
{ field: 'listprice', width: 80, align: 'right', title: 'List Pirce'
},
{ field: 'unitcost', width: 80, align: 'right', title: 'Unit Cost'
}]]
});
});
文章出处:http://www.cnblogs.com/huyong/p/4896958.html
转载于:https://www.cnblogs.com/foreverfendou/p/5091511.html
相关资源:JAVA上百实例源码以及开源项目