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

前端之家收集整理的这篇文章主要介绍了javascript – 如何在jqGrid中显示没有任何数据的信息?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当jqGrid为空时,我想在网格中显示单个空行,并显示没有任何数据的信息消息.这怎么可能?谢谢

解决方法

我正在寻找这个答案,并提出了以下解决方案,但我不是在与服务器交谈,所以我必须使用除’loadComplete’事件之外的东西.我联系到“gridComplete”事件,并检查是否有任何记录.如果没有,请显示您的空文本,否则隐藏它.
  1. jQuery('#test').jqGrid({
  2. ... // some settings
  3. 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.
  4. ... // more settings
  5.  
  6. });
  7.  
  8. function LoadComplete()
  9. {
  10. if ($('test').getGridParam('records') == 0) // are there any records?
  11. DisplayEmptyText(true);
  12. else
  13. DisplayEmptyText(false);
  14. }
  15.  
  16. function DisplayEmptyText( display)
  17. {
  18. var grid = $('#test');
  19. var emptyText = grid.getGridParam('emptyDataText'); // get the empty text
  20. var container = grid.parents('.ui-jqgrid-view'); // find the grid's container
  21. if (display) {
  22. container.find('.ui-jqgrid-hdiv,.ui-jqgrid-bdiv').hide(); // hide the column headers and the cells below
  23. container.find('.ui-jqgrid-titlebar').after('' + emptyText + ''); // insert the empty data text
  24. }
  25. else {
  26. container.find('.ui-jqgrid-hdiv,.ui-jqgrid-bdiv').show(); // show the column headers
  27. container.find('#EmptyData' + dataObject).remove(); // remove the empty data text
  28. }
  29. }

猜你在找的JavaScript相关文章