javascript - 如何在jqGrid中显示没有任何数据的信息?

标签 javascript jqgrid

当 jqGrid 为空时,我想在网格内显示单个空行,并显示没有任何数据的信息消息。这怎么可能?谢谢

最佳答案

我一直在寻找这个问题的答案并提出了以下解决方案,但我没有与服务器对话,所以我必须使用“loadComplete”事件之外的东西。我连接到“gridComplete”事件并检查是否有任何记录。如果不是,则显示您的空文本,否则将其隐藏。

<pre>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 } } </pre>

关于javascript - 如何在jqGrid中显示没有任何数据的信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1019155/

相关文章:

php - 创建动态 js 文件并缓存它?

javascript - 当用户单击链接时显示模式弹出窗口 jqgrid

javascript - 将自定义滚动条应用到jqgrid后,排序不起作用

jqGrid批量保存-编辑模式下如何获取所有行数据

javascript - 有没有办法在不重叠的情况下在绘图工具提示中显示文本?

javascript - 如何动态显示/Conceal facebook 登录按钮

javascript - chrome 和 firefox 之间的 window.innerWidth 不同?

javascript - 如何使用 jquery 在鼠标悬停时显示隐藏的 div?

jquery - 获取JQGrid格式化程序: ‘showlink’ to work in MVC

jquery - jqgrid 编辑表单失去浏览器自动填充功能