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

查看:23
本文介绍了使用 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
});

如果记录确实存在,那么一切看起来就像我期望的那样.我还需要做些什么来让 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天全站免登陆