From 785ae58b1bad391142c6b7225e15b47c51a0cbda Mon Sep 17 00:00:00 2001 From: Thibault Vilon Date: Fri, 17 Feb 2017 00:36:41 +0100 Subject: [PATCH] add onRowClick prop to Table --- build/reactable.js | 7 ++++++- lib/reactable/lib/filter_props_from.js | 3 ++- lib/reactable/table.js | 4 ++++ src/reactable/lib/filter_props_from.jsx | 4 ++-- src/reactable/table.jsx | 4 ++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/build/reactable.js b/build/reactable.js index 7671bed2..f8bd25cb 100644 --- a/build/reactable.js +++ b/build/reactable.js @@ -44,7 +44,8 @@ window.ReactDOM["default"] = window.ReactDOM; pageButtonLimit: true, childNode: true, data: true, - children: true + children: true, + onRowClick: true }; function filterPropsFrom(baseProps) { @@ -1455,6 +1456,10 @@ window.ReactDOM["default"] = window.ReactDOM; } } + if (this.props.onRowClick) { + props.onClick = this.props.onRowClick.bind(null, data); + } + return _react['default'].createElement(_tr.Tr, _extends({ columns: columns, key: i, data: data }, props)); }).bind(this))); } diff --git a/lib/reactable/lib/filter_props_from.js b/lib/reactable/lib/filter_props_from.js index b651549f..d574526c 100644 --- a/lib/reactable/lib/filter_props_from.js +++ b/lib/reactable/lib/filter_props_from.js @@ -32,7 +32,8 @@ var internalProps = { pageButtonLimit: true, childNode: true, data: true, - children: true + children: true, + onRowClick: true }; function filterPropsFrom(baseProps) { diff --git a/lib/reactable/table.js b/lib/reactable/table.js index e2235b66..19455756 100644 --- a/lib/reactable/table.js +++ b/lib/reactable/table.js @@ -462,6 +462,10 @@ var Table = (function (_React$Component) { } } + if (this.props.onRowClick) { + props.onClick = this.props.onRowClick.bind(null, data); + } + return _react2['default'].createElement(_tr.Tr, _extends({ columns: columns, key: i, data: data }, props)); }).bind(this))); } diff --git a/src/reactable/lib/filter_props_from.jsx b/src/reactable/lib/filter_props_from.jsx index 8631ede4..468a6819 100644 --- a/src/reactable/lib/filter_props_from.jsx +++ b/src/reactable/lib/filter_props_from.jsx @@ -26,7 +26,8 @@ const internalProps = { pageButtonLimit: true, childNode: true, data: true, - children: true + children: true, + onRowClick: true }; export function filterPropsFrom(baseProps) { @@ -40,4 +41,3 @@ export function filterPropsFrom(baseProps) { return props; } - diff --git a/src/reactable/table.jsx b/src/reactable/table.jsx index 82601180..a6a6c2d5 100644 --- a/src/reactable/table.jsx +++ b/src/reactable/table.jsx @@ -423,6 +423,10 @@ export class Table extends React.Component { } } + if (this.props.onRowClick) { + props.onClick = this.props.onRowClick.bind(null, data); + } + return ( );