默认情况下,当没有数据时,jqGrid 在寻呼机内显示消息“没有可查看的记录”
。 (我的网格使用顶部寻呼机)。
问题是,这条消息很容易被错过。
我想让网格在顶部标题下方显示消息,如果有任何数据,则在行显示的同一位置。 (在 body 层,如 documentation 中定义)。
或者,虽然不太理想,但我可以将消息保留在原来的位置,但以又大又胖的红色字体显示。
该消息应用了 css 类 ui-paging-info
,但我不能只更新它,因为当数据源时,sae 类还用于显示消息“找到 X 条记录” 不是空,而且我不希望那个又大又红:)。
从我在 jqGrid 源代码中看到的情况来看,该消息是在函数 updatepager
中设置的。
[...]
pgboxes = ts.p.pager || "";
pgboxes += ts.p.toppager ? (pgboxes ? "," + ts.p.toppager : ts.p.toppager) : "";
[...]
if(pgboxes) {
[...]
if (ts.p.viewrecords){
if(ts.p.reccount === 0) {
$(".ui-paging-info",pgboxes).html(ts.p.emptyrecords);
}
else [...]
我猜这就是我应该注入(inject)一些自定义逻辑的地方,但我不知道该怎么做。
我可以破解 jqGrid 源代码,但我不想 -> 这对于将来的 jqGrid 升级来说会很痛苦。
最佳答案
我在 the old answer 中描述过和 this one一种实现您的要求的方法。
The demo使用当前4.6.0版本的jqGrid并显示
如果需要显示某些数据,网格看起来像 another demo
如果我正确理解你的问题,演示应该可以满足你的需要。
关于jquery - jqGrid 没有数据 - 如何设置更突出的 'no data' 消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24609566/