微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – 如何在jqGrid中显示没有任何数据的信息?

当jqgrid为空时,我想在网格中显示单个空行,并显示没有任何数据的信息消息.这怎么可能?谢谢

解决方法

我正在寻找这个答案,并提出了以下解决方案,但我不是在与服务器交谈,所以我必须使用除’loadComplete’事件之外的东西.我联系到“gridComplete”事件,并检查是否有任何记录.如果没有,请显示您的空文本,否则隐藏它.
jQuery('#test').jqgrid({
        ... // some settings
        gridComplete: loadCompleteFunction,emptyDataText:'There are no records. If you would like to add one,click the "Add New ..." button below.',// you can name this parameter whatever you want.
        ... // more settings

});

function LoadComplete()
{
    if ($('test').getGridParam('records') == 0) // are there any records?
        displayEmptyText(true);
    else
        displayEmptyText(false);
}

function displayEmptyText( display)
{
    var grid = $('#test');
    var emptyText = grid.getGridParam('emptyDataText'); // get the empty text
    var container = grid.parents('.ui-jqgrid-view'); // find the grid's container
    if (display) {
        container.find('.ui-jqgrid-hdiv,.ui-jqgrid-bdiv').hide(); // hide the column headers and the cells below
        container.find('.ui-jqgrid-titlebar').after('' + emptyText + ''); // insert the empty data text
    }
    else {
        container.find('.ui-jqgrid-hdiv,.ui-jqgrid-bdiv').show(); // show the column headers
        container.find('#EmptyData' + dataObject).remove(); // remove the empty data text
    }
}

原文地址:https://www.jb51.cc/js/151995.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐