diff --git a/src/components/paginator/JumpToPageInput.js b/src/components/paginator/JumpToPageInput.js
index bccd215612..adf383c182 100644
--- a/src/components/paginator/JumpToPageInput.js
+++ b/src/components/paginator/JumpToPageInput.js
@@ -1,39 +1,58 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { InputNumber } from '../inputnumber/InputNumber';
+import { ObjectUtils } from '../utils/Utils';
export class JumpToPageInput extends Component {
static defaultProps = {
page: null,
rows: null,
+ pageCount: null,
disabled: false,
+ template: null,
onChange: null
}
static propTypes = {
page: PropTypes.number,
rows: PropTypes.number,
+ pageCount: PropTypes.number,
disabled: PropTypes.bool,
+ template: PropTypes.any,
onChange: PropTypes.func
}
constructor(props) {
super(props)
- this.inputChange = this.inputChange.bind(this);
+ this.onChange = this.onChange.bind(this);
}
- inputChange(event) {
+ onChange(event) {
if (this.props.onChange) {
this.props.onChange(this.props.rows * (event.value - 1), this.props.rows);
}
}
render() {
- return (
-
- )
+ const value = this.props.pageCount > 0 ? this.props.page + 1 : 0;
+ const element = ;
+
+ if (this.props.template) {
+ const defaultOptions = {
+ value,
+ onChange: this.onChange,
+ disabled: this.props.disabled,
+ className: 'p-paginator-page-input',
+ element,
+ props: this.props
+ };
+
+ return ObjectUtils.getJSXElement(this.props.template, defaultOptions);
+ }
+
+ return element;
}
}
diff --git a/src/components/paginator/Paginator.d.ts b/src/components/paginator/Paginator.d.ts
index 93e9689712..91876f7891 100644
--- a/src/components/paginator/Paginator.d.ts
+++ b/src/components/paginator/Paginator.d.ts
@@ -116,10 +116,12 @@ interface PaginatorCurrentPageReportOptions {
}
interface PaginatorJumpToPageInputOptions {
- page: number;
- rows: number
- disabled: boolean;
+ value: number;
onChange(first:number, rows: number): void;
+ disabled: boolean;
+ className: string;
+ element: JSX.Element;
+ props: PaginatorProps;
}
interface PaginatorTemplateOptions {
diff --git a/src/components/paginator/Paginator.js b/src/components/paginator/Paginator.js
index 96e42cca73..48afe94d90 100644
--- a/src/components/paginator/Paginator.js
+++ b/src/components/paginator/Paginator.js
@@ -119,10 +119,6 @@ export class Paginator extends Component {
return Math.floor(this.props.first / this.props.rows);
}
- currentPage() {
- return this.getPageCount() > 0 ? this.getPage() + 1 : 0;
- }
-
empty() {
let pageCount = this.getPageCount()
return pageCount === 0;
@@ -204,7 +200,7 @@ export class Paginator extends Component {
rows={this.props.rows} totalRecords={this.props.totalRecords} template={template} />;
break;
case 'JumpToPageInput':
- element = ;
+ element = ;
break;
default: