Home > widget-integration > FilterHandler > calcPageAction
FilterHandler.calcPageAction() method
Calculates the new page number based on action.
Determines the target page number from pagination actions like 'prev', 'next', or direct page number strings. Ensures page numbers don't go below 1. Override this method to add custom page calculation logic, such as skipping pages or implementing custom pagination behaviors.
Signature:
protected calcPageAction(currentPage: number, action: string): number;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
currentPage |
number |
Current page number (1-based) |
|
action |
string |
Action string: 'prev' for previous, 'next' for next, or numeric string for direct page |
Returns:
number
New page number (minimum 1)
Example
Extend to implement page skipping:
window.boostWidgetIntegration.extend('FilterHandler', (FilterHandler) => {
return class CustomFilterHandler extends FilterHandler {
protected calcPageAction(currentPage, action) {
switch (action) {
case 'prev':
// Jump back 2 pages instead of 1
return Math.max(1, currentPage - 2);
case 'next':
// Jump forward 2 pages instead of 1
return currentPage + 2;
default:
return super.calcPageAction(currentPage, action);
}
}
};
});