>" it should sho..." /> >" it should sho..." /> >" it should sho..."/>

Pagination logic

460 views Asked by At

Can any one please suggest me a idea for the achieving below pagination.

1 2 3 4 5 next>> 

suppose if you are clicking "next>>" it should show next set of pagination like below

6 7 8 9 10 next>> 

and control should be in 6th page

scenario:

1 2 3 4 5 next>> 

if we are in any of the page and clicking next>> should go to 6th page i.e next set's 1st page

ex: if we are in 2nd page and next>> should go to 6th page or 3rd page next>> go to 6th page??

Thanks in advance.

1

There are 1 answers

0
Dustin Tran On

If you checkout the pagingbar.isml there are several useful snippet

current = pdict.pagingmodel.start;
totalCount = pdict.pagingmodel.count;
pageSize = pdict.pagingmodel.pageSize;
pageURL = pdict.pageurl;
currentPage = pdict.pagingmodel.currentPage;
maxPage = pdict.pagingmodel.maxPage;

then you can defined the next-set of paging by

lr = 2; // number of explicit page links to the left and right
    if ( maxPage <= 2*lr )
    {
        rangeBegin = 0;
        rangeEnd = maxPage;
    }
    else
    {
        rangeBegin = Math.max( Math.min( currentPage - lr, maxPage - 2*lr ), 0 );
        rangeEnd = Math.min( (rangeBegin + (2*lr)), maxPage );
    }