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
    }
}

相关文章

前言 做过web项目开发的人对layer弹层组件肯定不陌生,作为l...
前言 前端表单校验是过滤无效数据、假数据、有毒数据的第一步...
前言 图片上传是web项目常见的需求,我基于之前的博客的代码...
前言 导出Excel文件这个功能,通常都是在后端实现返回前端一...
前言 众所周知,js是单线程的,从上往下,从左往右依次执行,...
前言 项目开发中,我们可能会碰到这样的需求:select标签,禁...