Separated Pager for Yii2 is quite similar to the LinkPager that it extents. The only difference is that the first and last page are always shown as page numbers which eliminates the need for the "first" and "last" buttons.
Add the following to the require section of your
Simply add the
pager property to your GridView and reference this class
GridView::widget([ 'dataProvider' => $dataProvider, ... 'pager' => [ 'class' => 'justinvoelker\separatedpager\LinkPager', ] ]);
Please note that specifying less than 7 pages won't produce useful results. Less than 7 pages of content is acceptable (will look like the standard LinkPager) but limiting the pager to something less than 7 pages will look and work poorly. Five pages and the pager is almost worthless. Less than 5 and it is worthless.
In addition to all of the standard LinkPager properties, one new property has been added,
separator, that specifies a string to be used to indicate that multiple pages are being omitted. The default separator is
Here is my preferred pager setup. A max of 7 pages, 'Previous' and 'Next' buttons spelled out that are hidden on extra-small screens.
'pager' => [ 'class' => 'justinvoelker\separatedpager\CustomLinkPager', 'maxButtonCount' => 7, 'prevPageLabel' => 'Previous', 'nextPageLabel' => 'Next', 'prevPageCssClass' => 'prev hidden-xs', 'nextPageCssClass' => 'next hidden-xs', ]
Keep in mind that setting css classes will overwrite the defaults rather than appending to them. If additional classes should be included (such as the 'hidden-xs' above) the original
next should be included as well (this is the same way the standard LinkPager functions).
The GitHub README will contain the full documentation for this extension and will be updated as necessary. This extension page merely serves as a quick reference and pointer to the GitHub information.
Please do not ask for help in the comments below. If you require assistance please seek answers in the forum or GitHub for this extension.