Skip to content

Commit

Permalink
Update ReactDataGrid API to group cell range event handlers under cel…
Browse files Browse the repository at this point in the history
…lRangeSelection prop
  • Loading branch information
rowanhill committed Jul 24, 2018
1 parent d97094d commit 80e49e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ class Example extends React.Component {
rowGetter={this.rowGetter}
rowsCount={this.state.rows.length}
minHeight={500}
onCellRangeSelectionStarted={this.onStart}
onCellRangeSelectionUpdated={this.onUpdate}
onCellRangeSelectionCompleted={this.onComplete}
cellRangeSelection={{
onStart: this.onStart,
onUpdate: this.onUpdate,
onComplete: this.onComplete
}}
/>
</div>
);
Expand All @@ -85,11 +87,11 @@ class Example extends React.Component {

const exampleDescription = (
<div>
<h4>onCellRangeSelectionStarted</h4>
<h4>cellRangeSelection.onStart</h4>
<p>Called on mousedown on a cell. Receives <code>selectedRange</code> (containing <code>topLeft</code> and <code>topRight</code>) as an argument.</p>
<h4>onCellRangeSelectionUpdated</h4>
<h4>cellRangeSelection.onUpdate</h4>
<p>Called on mouseover on a cell when dragging with the mouse, or when pressing shift+arrowkey. Receives <code>selectedRange</code> (containing <code>topLeft</code> and <code>topRight</code>) as an argument.</p>
<h4>onCellRangeSelectionCompleted</h4>
<h4>cellRangeSelection.onComplete</h4>
<p>Called on mouseup (anywhere) when dragging with the mouse, or when pressing shift+arrowkey.</p>
<p>Note: altering the selected range with shift+arrowkey will fire both an Updated and Completed event with each keystroke.</p>
<h4>Example</h4>
Expand Down
14 changes: 8 additions & 6 deletions packages/react-data-grid/src/ReactDataGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ class ReactDataGrid extends React.Component {
cellNavigationMode: PropTypes.oneOf(['none', 'loopOverRow', 'changeRow']),
onCellSelected: PropTypes.func,
onCellDeSelected: PropTypes.func,
onCellRangeSelectionStarted: PropTypes.func,
onCellRangeSelectionUpdated: PropTypes.func,
onCellRangeSelectionCompleted: PropTypes.func,
cellRangeSelection: PropTypes.shape({
onStart: PropTypes.func,
onUpdate: PropTypes.func,
onComplete: PropTypes.func
}),
onCellExpand: PropTypes.func,
enableDragAndDrop: PropTypes.bool,
onRowExpandToggle: PropTypes.func,
Expand Down Expand Up @@ -709,9 +711,9 @@ class ReactDataGrid extends React.Component {
onDragHandleDoubleClick={this.onDragHandleDoubleClick}
onCellSelected={this.props.onCellSelected}
onCellDeSelected={this.props.onCellDeSelected}
onCellRangeSelectionStarted={this.props.onCellRangeSelectionStarted}
onCellRangeSelectionUpdated={this.props.onCellRangeSelectionUpdated}
onCellRangeSelectionCompleted={this.props.onCellRangeSelectionCompleted}
onCellRangeSelectionStarted={this.props.cellRangeSelection && this.props.cellRangeSelection.onStart}
onCellRangeSelectionUpdated={this.props.cellRangeSelection && this.props.cellRangeSelection.onUpdate}
onCellRangeSelectionCompleted={this.props.cellRangeSelection && this.props.cellRangeSelection.onComplete}
onCommit={this.onCommit}
/>
</div>
Expand Down

0 comments on commit 80e49e1

Please sign in to comment.