使用jqGrid的emptyrecords选项

所以我有这个网格。 这是一个非常好的网格。 可爱,真的。 除非我没有任何东西填充它。 在这种情况下,我真的想要显示一条消息,指出“没有加载任何URL进行评估。”但是,我要么缺少一些关键的东西,要么就是emptyrecords选项不符合我的预期。 有人能指出我正确的方向吗?

 var pages = ; $('#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消息吗?

我正在使用jqGrid 3.8。

谢谢。

您应该validationdata参数的值(您的情况下的pages值)。 我想该值为null{}而不是[]

更新 :您还可以考虑将当前页面从1设置为0,以显示小型演示 。

更新2 :原因是您可以在表格的位置放置有关空行的文本。 如果你必须删除height: 'auto' ,以便能够看到文本。 看看另一个演示这个的演示 。

如果此处的任何人都有问题,而JQGrid没有显示“No Records To View”消息,请确保已设置viewrecords: true选项。

emptyrecords – 当返回的(或当前)记录数为零时显示信息。 仅当viewrecords选项设置为true时,此选项才有效。