Skip to content

Commit

Permalink
Fixed #899 - Added resetColumnOrder method to DataTable
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed May 22, 2019
1 parent 8b94ecd commit 2588ad8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,12 @@ export class DataTable extends Component {
getTotalRecords(data) {
return this.props.lazy ? this.props.totalRecords : data ? data.length : 0;
}

resetColumnOrder() {
let columns = React.Children.toArray(this.props.children);

this.setState({columnOrder: columns});

This comment has been minimized.

Copy link
@Bublade

Bublade May 22, 2019

possible bug, columnOrder is set to string[] made by column.props.columnKey || column.props.field in onColumnDrop but here it is a JSX.Element[] and used as a string[] in getColumns

This comment has been minimized.

Copy link
@mertsincan

mertsincan May 22, 2019

Author Member

Good catch! Fixed now.

This comment has been minimized.

Copy link
@Bublade

Bublade May 22, 2019

maybe consider converting to typescript? In typescript issues like these are directly visible (we converted about 2 years ago at my work and we produce far less (typings) bugs)

}

renderLoader() {
let iconClassName = classNames('p-datatable-loading-icon pi-spin', this.props.loadingIcon);
Expand Down

0 comments on commit 2588ad8

Please sign in to comment.