Skip to content

Commit

Permalink
Fixed #1870 - Datatable rows per page doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Mar 15, 2021
1 parent 609747d commit 720ed53
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/components/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ export class DataTable extends Component {

constructor(props) {
super(props);
this.state = {};
this.state = {
d_rows: props.rows
};

if (!this.props.onPage) {
this.state.first = props.first;
Expand Down Expand Up @@ -530,7 +532,6 @@ export class DataTable extends Component {

createPaginator(position, totalRecords, data) {
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}
totalRecords={totalRecords} rowsPerPageOptions={this.props.rowsPerPageOptions} currentPageReportTemplate={this.props.currentPageReportTemplate}
Expand Down Expand Up @@ -1463,9 +1464,10 @@ export class DataTable extends Component {
}

static getDerivedStateFromProps(nextProps, prevState) {
if (nextProps.rows !== prevState.rows && !nextProps.onPage) {
if (nextProps.rows !== prevState.d_rows && !nextProps.onPage) {
return {
rows: nextProps.rows
rows: nextProps.rows,
d_rows: nextProps.rows
}
}

Expand Down

0 comments on commit 720ed53

Please sign in to comment.