Skip to content

Commit

Permalink
Fixed #1225 - New options for CurrentPageReport
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Mar 9, 2020
1 parent 4ab2eab commit 2e7141c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
12 changes: 11 additions & 1 deletion src/components/paginator/CurrentPageReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,29 @@ export class CurrentPageReport extends Component {
static defaultProps = {
pageCount: null,
page: null,
first: null,
rows: null,
totalRecords: null,
template: '({currentPage} of {totalPages})'
}

static propTypes = {
pageCount: PropTypes.number,
page: PropTypes.number,
first: PropTypes.number,
rows: PropTypes.number,
totalRecords: PropTypes.number,
template: PropTypes.string
}

render() {
let text = this.props.template
.replace("{currentPage}", this.props.page + 1)
.replace("{totalPages}", this.props.pageCount);
.replace("{totalPages}", this.props.pageCount)
.replace("{first}", this.props.first + 1)
.replace("{last}", this.props.first + this.props.rows)
.replace("{rows}", this.props.rows)
.replace("{totalRecords}", this.props.pageCount);

return <span className="p-paginator-current">{text}</span>
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/paginator/Paginator.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ export class Paginator extends Component {
break;

case 'CurrentPageReport':
element = <CurrentPageReport template={this.props.currentPageReportTemplate} key={key} page={this.getPage()} pageCount={this.getPageCount()} />;
element = <CurrentPageReport template={this.props.currentPageReportTemplate} key={key}
page={this.getPage()} pageCount={this.getPageCount()} first={this.props.first}
rows={this.props.rows} totalRecords={this.props.totalRecords} />;
break;

default:
Expand Down
4 changes: 3 additions & 1 deletion src/showcase/datatable/DataTableDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,9 @@ export class DataTableStateDemo extends Component {
<td>currentPageReportTemplate</td>
<td>string</td>
<td>(&#123;currentPage&#125; of &#123;totalPages&#125;)</td>
<td>Template of the current page report element.</td>
<td>Template of the current page report element. Available placeholders are
&123;currentPage&125;,&123;totalPages&125;,&123;rows&125;,&123;first&125;,&123;last&125; and &123;totalRecords&125;
</td>
</tr>
<tr>
<td>first</td>
Expand Down
4 changes: 3 additions & 1 deletion src/showcase/paginator/PaginatorDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ import {Paginator} from 'primereact/paginator';
<td>currentPageReportTemplate</td>
<td>string</td>
<td>(&123;currentPage&125; of &123;totalPages&125;)</td>
<td>Template of the current page report element.</td>
<td>Template of the current page report element. Available placeholders are
&123;currentPage&125;,&123;totalPages&125;,&123;rows&125;,&123;first&125;,&123;last&125; and &123;totalRecords&125;
</td>
</tr>
</tbody>
</table>
Expand Down
4 changes: 3 additions & 1 deletion src/showcase/treetable/TreeTableDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,9 @@ export class TreeTableResponsiveDemo extends Component {
<td>currentPageReportTemplate</td>
<td>string</td>
<td>(&123;currentPage&125; of &123;totalPages&125;)</td>
<td>Template of the current page report element.</td>
<td>Template of the current page report element. Available placeholders are
&123;currentPage&125;,&123;totalPages&125;,&123;rows&125;,&123;first&125;,&123;last&125; and &123;totalRecords&125;
</td>
</tr>
<tr>
<td>first</td>
Expand Down

0 comments on commit 2e7141c

Please sign in to comment.