使用jqGrid的emptyrecords选项 [英] Using jqGrid's emptyrecords option

查看:365
本文介绍了使用jqGrid的emptyrecords选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有这个网格.这是一个非常不错的网格.可爱,真的.除非我什么都没有填充.在那种情况下,我真的很想显示一条消息,指出尚未加载任何URL进行评估.",但是我错过了一些关键信息,或者emptyrecords选项没有按照我的方式运行预计.有人可以指出我正确的方向吗?

So I have this grid. It's a very nice grid. Lovely, really. Except when I have nothing to populate it with. In that case, I'd really like to display a message indicating that, "No URLs have been loaded for evaluation.", but either I'm missing something critical or the emptyrecords option isn't behaving the way I'd expect. Can someone point me in the right direction?

var pages = <?php echo $json_encoded_array ?>;

$('#oversight-sample').jqGrid({
  altRows:   true,
  autowidth: true,
  caption:   'Evaluated URLs',
  colNames:  ['Actions', 'URL', 'Fetch Date'],
  colModel:  [
    { align: 'center', name: 'actions', index: 'actions', title: false, width: 60, resizable: false, sortable: false },
    { name: 'url', index: 'url', width: 400 },
    { align: 'center', name: 'created', index: 'created', width: 125, sorttype: 'date' }
  ],
  data:         pages,
  datatype:     'local',
  emptyrecords: 'No URLs have been loaded for evaluation.',
  forceFit:     true,
  height:       'auto',
  hoverrows:    true,
  sortname:     'created',
  pager:        '#url-pager',
  viewrecords:  true
});

如果记录 do 存在,那么一切看起来都与我期望的一样.我还需要做些其他的事情来使emptyrecords消息在不存在时显示吗?

If records do exist, then everything looks about like I'd expect it to look. Is there something else I need to do to get the emptyrecords message to display when there are none?

我正在使用jqGrid 3.8.

I'm using jqGrid 3.8.

谢谢.

推荐答案

您应该验证data参数的值(在您的情况下为pages的值)如何.我想值是null{}而不是[].

You should verify how are the value of data parameter (the value of pages in your case). I suppose the value is null or {} instead of [].

已更新:您还可以考虑将当前页面的显示方式从1设置为0,以显示

UPDATED: You can also consider to set current page from 1 to 0 how it shows the small demo.

更新2 :因此,您可以将有关空行的文本放置在表的位置.在这种情况下,您必须删除height: 'auto'才能看到文本.查看另一个演示,其中显示了此内容.

UPDATED 2: Of cause you can place the text about empty rows on the place of the table. In the case you have to remove height: 'auto' to be able to see the text. Look at another demo which show this.

这篇关于使用jqGrid的emptyrecords选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆