Unable to position pager (navigation bar) above jqGrid

北城余情 提交于 2019-11-26 02:38:50

问题


According the the jqGrid documentation, I should be able to place the pager above or below the jqGrid by moving the pager div. Unfortunately, the pager always renders below the grid.

<div id=\"pager\"></div>
<table id=\"list\">
    <tr>
        <td />
    </tr>
</table>

The jqGrid configuration (related to the pager) looks like:

pager: \'#pager\',
pginput: false,
pgbuttons: false,

Any suggestions?


回答1:


You should use toppager:true jqGrid option instead. You don't need define <div id="pager"></div> and use pager: '#pager' parameter. The id of the pager from the top of jqGrid will be "list_toppager" (id of the table element appended with "_toppager").

If you want to add navigator you can use

$("#list").jqGrid('navGrid','#list_toppager');

If you use define <div id="pager"></div> and use pager: '#pager' parameter you will have two pager: one with id="list_toppager" on top of the grid and anothe with id="pager" on the bottom. If you want use both top and bottom pager you can use

$("#list").jqGrid('navGrid','#pager',{cloneToTop:true});

and then move or remove (see another answer for more details and the demo example). You can also very easy move buttons from one toolbar to the other using jQuery.insertAfter function (see here).




回答2:


use a $ append. the html above table is like this

<div id="export"></div>                        

add the id and use a promise().done(): "exportButton"

$(grid).jqGrid('navButtonAdd', self.options.pagerSelector, { id: "exportButton", caption: "Export to CSV", buttonicon: "ui-icon-newwin", onClickButton: function() { self._exportToCSV(self, grid); }, position: "last", title: "Export to CSV", cursor: "pointer" })
.promise().done(function() {
    //reposition export button
    $("#export").append($("#exportButton"));
    $("#exportButton").addClass("pull-right").show();
});


来源:https://stackoverflow.com/questions/4402455/unable-to-position-pager-navigation-bar-above-jqgrid

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