Binding to Bootstrap pagination component.
<div data-bind="pagination: { currentPage: page, totalCount: total, maxPages: maxPages, directions: directions, boundary: boundary, text: text }"></div>
function PaginationExampleViewModel() {
this.page = ko.observable(1);
this.total = ko.observable(100);
this.maxPages = ko.observable(5);
this.directions = ko.observable(true);
this.boundary = ko.observable(true);
this.text = {
first: ko.observable('First'),
last: ko.observable('Last'),
back: ko.observable('«'),
forward: ko.observable('»')
};
}
All of the options can be observables.
data-bind="pagination: { currentPage: page, totalCount: count, pageSize: size, maxPages: maxPages, directions: directions, boundary: boundary, text: textObj }"
currentPage
Type: number, should be observable (default: 1)
Contains selected page.
totalCount
Type: number, can be observable
Contains total count of items, for which paging is used. Used to determine pages amount.
pageSizes
Type: number, can be observable (default: 10)
Specifies amount of items per page. Used to determine pages amount.
maxPages
Type: number, can be observable (default: 5)
Specifies maximum amount of pages, which will be displayed in pagaination control.
directions
Type: boolean, can be observable (default: true)
Specifies, should back and forward buttons be displayed.
boundary
Type: boolean, can be observable (default: true)
Specifies, should last and first buttons be displayed.
text
Type: object, can be observable
Contains text for first, last, back and forward buttons.
Default values of text object:
first
Type: string, can be observable (default: 'First')
Contains text for "First" button
last
Type: string, can be observable (default: 'Last')
Contains text for "Last" button
back
Type: string, can be observable (default: '«')
Contains text for "Back" button
forward
Type: string, can be observable (default: '»')
Contains text for "Forward" button