Disable Next/Last Pager in jqgrid

此生再无相见时 提交于 2019-12-25 06:59:06

问题


I'm using jqGrid in which the Next/Last pager is enabled even when there is no records in the jqgrid during a filter condition is applied.

I have a demo of @Oleg, in which first select "5" in the number of rows displayed in the pager. Then filter the grid in which it shows no records. Now you can see the Next/Last pager button still enabled while the Previous/first is disabled.

I need to disable the First/Previous, Next/Last and the rowList(5,10,20,50).

I'm using the datatype:local but i dont use loadonce:true.

Here is the Demo


回答1:


I suppose that you use datatype: "local" or datatype: "json" or datatype: "xml" together with loadonce: true. In the case I would recommend you to add the following localReader:

localReader: {
    page: function (obj) {
        if (obj.rows == null || obj.rows.length === 0) {
            return "0";
        }
    }
}

It should fix the problem with enabled Next and Last buttons in the pager.




回答2:


Debugging the code i found this, Modifying the code of @Oleg.

This works fine for me:

localReader: {
    page: function (obj) {
        if (obj.rows == null || obj.rows.length === 0) {
            return "0";
        } 
    }
}

The else part gets the row count of the page and bind it to the pager. So the grid gets collapsed.

Thanks @Oleg for your answer.



来源:https://stackoverflow.com/questions/27268215/disable-next-last-pager-in-jqgrid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!