如何在jqGrid中显示没有任何数据的信息? [英] How to display information in jqGrid that there are not any data?
本文介绍了如何在jqGrid中显示没有任何数据的信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当jqGrid为空时,我想在网格内显示单个空行,并显示没有任何数据的信息消息。这怎么可能?谢谢
When jqGrid is empty I want to display single empty row inside the grid with information message that there are not any data. How is this possible? Thanks
推荐答案
我一直在寻找这个问题的答案,并提出了以下解决方案,但我不是在和服务器,所以我必须使用'loadComplete'事件以外的东西。我迷上了'gridComplete'事件并检查是否有任何记录。如果没有,请显示空白文本,否则将其隐藏。
I was looking for answer to this one and came up with the following solution, but I'm not talking to the server, so I have to using something besides the 'loadComplete' event. I hooked into the 'gridComplete' event and check to see if there are any records. If not, display your empty text, otherwise hide it.
jQuery('#test').jqGrid({
... // some settings
gridComplete: loadCompleteFunction,
emptyDataText:'There are no records. If you would like to add one, click the "Add New ..." button below.', // you can name this parameter whatever you want.
... // more settings
});
function LoadComplete()
{
if ($('test').getGridParam('records') == 0) // are there any records?
DisplayEmptyText(true);
else
DisplayEmptyText(false);
}
function DisplayEmptyText( display)
{
var grid = $('#test');
var emptyText = grid.getGridParam('emptyDataText'); // get the empty text
var container = grid.parents('.ui-jqgrid-view'); // find the grid's container
if (display) {
container.find('.ui-jqgrid-hdiv, .ui-jqgrid-bdiv').hide(); // hide the column headers and the cells below
container.find('.ui-jqgrid-titlebar').after('' + emptyText + ''); // insert the empty data text
}
else {
container.find('.ui-jqgrid-hdiv, .ui-jqgrid-bdiv').show(); // show the column headers
container.find('#EmptyData' + dataObject).remove(); // remove the empty data text
}
}
这篇关于如何在jqGrid中显示没有任何数据的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文