Skip to content

Commit

Permalink
Fixed #1840 - Add paginatorClassName to DataTable, TreeTable and Data…
Browse files Browse the repository at this point in the history
…View
  • Loading branch information
mertsincan committed Mar 4, 2021
1 parent 2943570 commit 6e82bfc
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/components/datatable/DataTable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface DataTableProps {
paginator?: boolean;
paginatorPosition?: string;
alwaysShowPaginator?: boolean;
paginatorClassName?: string;
paginatorTemplate?: string | object;
paginatorLeft?: any;
paginatorRight?: any;
Expand Down
4 changes: 3 additions & 1 deletion src/components/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class DataTable extends Component {
paginator: false,
paginatorPosition: 'bottom',
alwaysShowPaginator: true,
paginatorClassName: null,
paginatorTemplate: 'FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown',
paginatorLeft:null,
paginatorRight: null,
Expand Down Expand Up @@ -126,6 +127,7 @@ export class DataTable extends Component {
paginator: PropTypes.bool,
paginatorPosition: PropTypes.string,
alwaysShowPaginator: PropTypes.bool,
paginatorClassName: PropTypes.string,
paginatorTemplate: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
paginatorLeft: PropTypes.any,
paginatorRight: PropTypes.any,
Expand Down Expand Up @@ -519,7 +521,7 @@ export class DataTable extends Component {
}

createPaginator(position, totalRecords, data) {
let className = 'p-paginator-' + position;
const className = classNames('p-paginator-' + position, this.props.paginatorClassName);

return (
<Paginator first={this.getFirst()} rows={this.getRows()} pageLinkSize={this.props.pageLinkSize} className={className} onPageChange={this.onPageChange} template={this.props.paginatorTemplate}
Expand Down
1 change: 1 addition & 0 deletions src/components/dataview/DataView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface DataViewProps {
paginator?: boolean;
paginatorPosition?: string;
alwaysShowPaginator?: boolean;
paginatorClassName?: string;
paginatorTemplate?: string | object;
paginatorLeft?: any;
paginatorRight?: any;
Expand Down
4 changes: 3 additions & 1 deletion src/components/dataview/DataView.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class DataView extends Component {
paginator: false,
paginatorPosition: 'bottom',
alwaysShowPaginator: true,
paginatorClassName: null,
paginatorTemplate: 'FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown',
paginatorLeft:null,
paginatorRight: null,
Expand Down Expand Up @@ -121,6 +122,7 @@ export class DataView extends Component {
paginator: PropTypes.bool,
paginatorPosition: PropTypes.string,
alwaysShowPaginator: PropTypes.bool,
paginatorClassName: PropTypes.string,
paginatorTemplate: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
paginatorLeft: PropTypes.any,
paginatorRight: PropTypes.any,
Expand Down Expand Up @@ -162,7 +164,7 @@ export class DataView extends Component {
}

createPaginator(position) {
const className = 'p-paginator-' + position;
const className = classNames('p-paginator-' + position, this.props.paginatorClassName);
const first = this.props.onPage ? this.props.first: this.state.first;
const rows = this.props.onPage ? this.props.rows : this.state.rows;
const totalRecords = this.getTotalRecords();
Expand Down
1 change: 1 addition & 0 deletions src/components/treetable/TreeTable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface TreeTableProps {
paginator?: boolean;
paginatorPosition?: string;
alwaysShowPaginator?: boolean;
paginatorClassName?: string;
paginatorTemplate?: string | object;
paginatorLeft?: any;
paginatorRight?: any;
Expand Down
4 changes: 3 additions & 1 deletion src/components/treetable/TreeTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class TreeTable extends Component {
paginator: false,
paginatorPosition: 'bottom',
alwaysShowPaginator: true,
paginatorClassName: null,
paginatorTemplate: 'FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown',
paginatorLeft:null,
paginatorRight: null,
Expand Down Expand Up @@ -96,6 +97,7 @@ export class TreeTable extends Component {
paginator: PropTypes.bool,
paginatorPosition: PropTypes.string,
alwaysShowPaginator: PropTypes.bool,
paginatorClassName: PropTypes.string,
paginatorTemplate: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
paginatorLeft: PropTypes.any,
paginatorRight: PropTypes.any,
Expand Down Expand Up @@ -916,7 +918,7 @@ export class TreeTable extends Component {
}

createPaginator(position, totalRecords) {
const className = 'p-paginator-' + position;
const className = classNames('p-paginator-' + position, this.props.paginatorClassName);

return (
<Paginator first={this.getFirst()} rows={this.getRows()} pageLinkSize={this.props.pageLinkSize} className={className}
Expand Down
8 changes: 7 additions & 1 deletion src/showcase/datatable/DataTableDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2518,7 +2518,7 @@ const bodyTemplate = (data, props) => {
</tr>
<tr>
<td>tableClassName</td>
<td>any</td>
<td>string</td>
<td>null</td>
<td>Style class of the table element.</td>
</tr>
Expand All @@ -2540,6 +2540,12 @@ const bodyTemplate = (data, props) => {
<td>true</td>
<td>Whether to show it even there is only one page.</td>
</tr>
<tr>
<td>paginatorClassName</td>
<td>string</td>
<td>null</td>
<td>Style class of the paginator element.</td>
</tr>
<tr>
<td>paginatorTemplate</td>
<td>string|object</td>
Expand Down
6 changes: 6 additions & 0 deletions src/showcase/dataview/DataViewDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,12 @@ const onSortChange = (event) => {
<td>true</td>
<td>Whether to show it even there is only one page.</td>
</tr>
<tr>
<td>paginatorClassName</td>
<td>string</td>
<td>null</td>
<td>Style class of the paginator element.</td>
</tr>
<tr>
<td>paginatorTemplate</td>
<td>string|object</td>
Expand Down
6 changes: 6 additions & 0 deletions src/showcase/treetable/TreeTableDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,12 @@ export const TreeTableResponsiveDemo = () => {
<td>true</td>
<td>Whether to show it even there is only one page.</td>
</tr>
<tr>
<td>paginatorClassName</td>
<td>string</td>
<td>null</td>
<td>Style class of the paginator element.</td>
</tr>
<tr>
<td>paginatorTemplate</td>
<td>string|object</td>
Expand Down

0 comments on commit 6e82bfc

Please sign in to comment.