没有数据的jqGrid-如何设置更突出的“无数据"消息? [英] jqGrid with no data - how to set a more prominent 'no data' message?

查看:71
本文介绍了没有数据的jqGrid-如何设置更突出的“无数据"消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,当没有数据时,jqGrid在寻呼机内显示消息'No records to view'. (我的网格使用顶部的寻呼机).

By default, when having no data, jqGrid displays the message 'No records to view' inside a pager. (My grids use the top pager).

问题是,该消息很容易丢失.

The problem is, the message is easy to miss.

我想使网格在顶部标头下方显示消息,该位置在有数据的情况下显示行的位置相同. (在主体层中,如文档).

I'd like to make the grid display the message below the top header, in the same place where the rows would show up if there was any data. (in the body layer, as defined in the documentation).

或者,尽管不太理想,但可以将消息保留在原处,但是以大而胖的红色字体显示该消息.

Alternatively, though less desirable, I'd be fine with leaving the message where it is, but showing it in a big, fat, red font-face.

该消息已应用css类ui-paging-info,但我不能仅仅更新它,因为当数据源为 not 时,sae类还用于显示消息找到X记录"是空的,我不希望那个大而红色:).

The message has css class ui-paging-info applied, but I can't just update that because the sae class is also used for displaying the message 'X records found', when the datasource is not empty, and I don't want that to be big and red :).

根据我在jqGrid源代码中看到的内容,该消息是在函数updatepager中设置的.

From what I've seen in the jqGrid source, the message is set in the function 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 [...]

我猜这是我应该注入一些自定义逻辑的地方,但是我不确定该怎么做.

I'm guessing that's where I should be injecting some custom logic, but I'm not sure how to do that.

我可以破解jqGrid源,但我不希望->这对于将来的jqGrid升级会很痛苦.

I could just hack the jqGrid source, but I'd rather not -> that would be painful for future jqGrid upgrades.

推荐答案

我在旧答案这一个一种如何实现您的要求的方法.

I described in the old answer and this one a way how one can implement your requirements.

该演示使用jqGrid的当前4.6.0版本并显示

The demo uses the current 4.6.0 version of jqGrid and displays

如果需要显示一些数据,则网格看起来像另一个演示

In case of some data need be displayed the grid looks like on another demo

如果我正确理解了您的问题,演示程序将按照您的要求进行操作.

If I correctly understand your question the demos should do what you need.

这篇关于没有数据的jqGrid-如何设置更突出的“无数据"消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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