-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pager becomes long for large amount of pages #22
Comments
Yeah, this is true, though it's technically not a part of DataTable core. We could turn the pagination block in the example view into a mixin and implement it there |
GMTA, I just thought of the same thing :) I would argue that since DataTable already contains pagination-specific logic (e.g. gotoPage) it makes sense for it to support such "constrained" pagination. Moreover, the way we bind to pages now is a bit hackish ( <ul class="pagination" data-bind="foreach: pages">
<li data-bind="css: class">
<a href="#" data-bind="text: text, click: gotoAssociatedPage"></a>
</li>
</ul> Making it constrained (e.g. show N pages before and after current, where N is a ctor parameter) shouldn't be difficult. Support for "jumps" (e.g. go 10 forward) would be a nice touch as well. |
@ohadschn I like that idea. |
I've been doing some thinking about where the line should be drawn between the view and view model (VM). I believe the following observables should be dropped from the VM (knockout-datatable) and handled in the view (HTML):
What do you think? |
I think those are great ideas, but I don't want to lose the easy access to these helper methods. Perhaps we could extract these methods into an opt-in extension of DataTable, e.g. by exposing a |
I understand the temptation, but I think we should not give in to the dark side :) |
@cmbankester any thoughts on this? BTW in the meantime it's pretty simple to implement on the view: <!-- ko foreach: {data: (new Array(pages()))} -->
<li data-bind="visible: Math.abs($index()+1-$parent.currentPage()) <= (4 + Math.max(0, 5-$parent.currentPage()) + Math.max(0, $parent.currentPage()+4-$parent.pages())), css: $parent.pageClass($index() + 1)">
<a href="#" data-bind="css: 'fixed-page', text: $index() + 1, click: $parent.gotoPage($index() + 1)"></a>
</li>
<!-- /ko -->
.fixed-page {
width: 50px;
text-align: center;
} |
The pagination area can become large when paginating a table that contains many pages. Maybe we should show an ellipsis when
pages
is greater than say 15.The text was updated successfully, but these errors were encountered: