Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set sort column and direction with props #649

Merged
merged 7 commits into from
Mar 19, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/react-data-grid/src/ReactDataGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const RowUtils = require('./RowUtils');
const ColumnUtils = require('./ColumnUtils');
const KeyCodes = require('./KeyCodes');
import AppConstants from './AppConstants';
import { DEFINE_SORT } from './cells/headerCells/SortableHeaderCell';
require('../../../themes/react-data-grid-core.css');
require('../../../themes/react-data-grid-checkbox.css');

Expand Down Expand Up @@ -67,6 +68,8 @@ const ReactDataGrid = React.createClass({
onCellsDragged: React.PropTypes.func,
onAddFilter: React.PropTypes.func,
onGridSort: React.PropTypes.func,
sortColumn: React.PropTypes.string,
sortDirection: React.PropTypes.oneOf(Object.keys(DEFINE_SORT)),
onDragHandleDoubleClick: React.PropTypes.func,
onGridRowsUpdated: React.PropTypes.func,
onRowSelect: React.PropTypes.func,
Expand Down Expand Up @@ -140,6 +143,12 @@ const ReactDataGrid = React.createClass({
} else {
initialState.selected = {rowIdx: -1, idx: -1};
}

if (this.props.sortColumn && this.props.sortDirection) {
initialState.sortColumn = this.props.sortColumn;
initialState.sortDirection = this.props.sortDirection;
}

return initialState;
},

Expand Down