English 中文(简体)
添加数字页数,用于jqGrid
原标题:Add numeric pager to jqGrid

是否有任何人知道如何设立支架,以使用一个数字页面器?

Instead of Page 1 of 20, I want to have the paging be like 1,2,3,4 > >> and when I click on 4 it would something like << < 4,5,6,7 > >>

I ve seen how other grids do it, but I can t seem to find a built in way for jqGrid to do it. I may have a way to implement it, but I don t want to reinvent the wheel if there is something already out there. It would involve me adding custom buttons after getting userdata from the grid s data to determine the pages available.

Telerik s grid do it (http://demos.telerik.com/aspnet-mvc/grid).

最佳回答

Ohhh! 期间 我写了《火法》的另一份版本。 然而,两个工作版本比任何人都好。

我做了小的解说,说明如何执行与页数链接的行为。 我这样说了,这样它就能够以表格的形式显示页数。

“entergraph

(如果pginput: mis para amount of jqGrid are used) or in form

“entergraph

在这两种情况下,本页不会在名单上展示。 如何看到我插入这些联系的强调风格。 如果你不喜欢,你就应当删除。

td.myPager a { text-decoration:underline !important }

页: 1 http://www.ok-soft-gmbh.com/jqGrid/Simple LocalGridWithLinkPager.htm”rel=“noretinger”>here和here

相应的 Java本代码全文载于<代码>Complete。 活动手稿:

loadComplete: function() {
    var i, myPageRefresh = function(e) {
        var newPage = $(e.target).text();
        grid.trigger("reloadGrid",[{page:newPage}]);
        e.preventDefault();
    };

    $(grid[0].p.pager +  _center td.myPager ).remove();
    var pagerPrevTD = $( <td> , { class: "myPager"}), prevPagesIncluded = 0,
        pagerNextTD = $( <td> , { class: "myPager"}), nextPagesIncluded = 0,
        totalStyle = grid[0].p.pginput === false,
        startIndex = totalStyle? this.p.page-MAX_PAGERS*2: this.p.page-MAX_PAGERS;
    for (i=startIndex; i<=this.p.lastpage && (totalStyle? (prevPagesIncluded+nextPagesIncluded<MAX_PAGERS*2):(nextPagesIncluded<MAX_PAGERS)); i++) {
        if (i<=0 || i === this.p.page) { continue; }

        var link = $( <a> , { href: # , click:myPageRefresh });
        link.text(String(i));
        if (i<this.p.page || totalStyle) {
            if (prevPagesIncluded>0) { pagerPrevTD.append( <span>,&nbsp;</span> ); }
            pagerPrevTD.append(link);
            prevPagesIncluded++;
        } else {
            if (nextPagesIncluded>0 || (totalStyle && prevPagesIncluded>0)) { pagerNextTD.append( <span>,&nbsp;</span> ); }
            pagerNextTD.append(link);
            nextPagesIncluded++;
        }
    }
    if (prevPagesIncluded > 0) {
        $(grid[0].p.pager +  _center td[id^="prev"] ).after(pagerPrevTD);
    }
    if (nextPagesIncluded > 0) {
        $(grid[0].p.pager +  _center td[id^="next"] ).before(pagerNextTD);
    }
}

where grid and MAX_PAGERS are defined as

var grid = $("#list"), MAX_PAGERS = 2;
问题回答

就我所知,在酒吧没有解决办法,你必须这样做。 (一) 页码:

function jqgridCreatePager(pagernav,navgrid,pages){
    $( # +pagernav+  # +pagernav+ _center td:has(input) ).attr( id , pager );
    var td = $( # +pagernav+  # +pagernav+ _center #pager ).html(  );
    var page = parseInt(jQuery("#"+navgrid).jqGrid( getGridParam , page ))
    var lastPage = parseInt(jQuery("#"+navgrid).jqGrid( getGridParam , lastpage ))
    text=  ;
    if(page-pages > 1){
            text+=jqgridCreatePageLink(navgrid,1)
            text+=   ...  
    }
    for(var i=0;i <pages;i++){
        if(page-pages+i >=1)
            text+=jqgridCreatePageLink(navgrid,page-pages+i)
    }

    text +=jqgridCreatePageLink(navgrid,page,true);

    for(var i=0;i <pages;i++){
        if(page+i+1 <= lastPage) 
            text +=jqgridCreatePageLink(navgrid,page+i+1)
    }

    if(page+pages <= lastPage){
        text+=   ...  
        text+=jqgridCreatePageLink(navgrid,lastPage)

    }
    var td = $( # +pagernav+  # +pagernav+ _center #pager ).html(text);
}

正在建立联系和发挥职能

function jqgridCreatePageLink(navgrid,page,current){
    if (!current)
        return   <a href="#" onclick="jQuery( # +navgrid+  ).jqGrid( setGridParam ,{page: +page+ }).trigger( reloadGrid )"> +page+ </a>  ;
    return   > +page+ <  
}

如今,在电网创建时,将这一代码与电网结合起来,或者像以下那样:

//create 
jqgridCreatePager( yourGridNavigator , yourGrid ,3)

并随函附上关于工资活动的报告。

//onPage
jqgridCreatePager( yourGridNavigator , yourGrid ,3)

防止浮油只增加贵重物品

#yourGridNavigator_center{
 display:none;
}

并且再次加入电网。

$( #yourGridNavigator_center ).show();

功能参数:

  • first is your grid navigator id
  • second is your grid id
  • this third parameter of the function is how many pages should be displayed before and after current page

这里还有一种可能的解决办法。

它用一个链接清单取代文字箱。

loadComplete: function() {
    var grid = this;
    var container = jQuery("#prev_jqGridTablePager").next().next();
    jQuery(container).html(  );

    var totalPages = grid.p.lastpage;
    for (var i = 1; i <= totalPages; i++) {
        if (i == grid.p.page) {
            jQuery(container).append("<span class= pagination current >" + i + "</span>");
        } else {
            jQuery(container).append("<a class= pagination  href= javascript: void(0) >" + i + "</a>");
        }
    }

    jQuery(container).find("a.pagination").click(function(e) {
        e.preventDefault();

        var newPage = jQuery(this).text();
        jQuery(grid).trigger("reloadGrid", [{ page: newPage }]);
    });
}




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签