@@ -106,6 +106,36 @@ function makeRenderer(opts = {}) {
106106 }
107107 }
108108
109+ // PutClickHandler
110+ // this.props.rendererOptions.table.clickCallback
111+ const getClickHandler =
112+ this . props . rendererOptions &&
113+ this . props . rendererOptions . table &&
114+ this . props . rendererOptions . table . clickCallback
115+ ? ( value , rowValues , colValues ) => {
116+ const filters = { } ;
117+ for ( const i of Object . keys ( colAttrs || { } ) ) {
118+ const attr = colAttrs [ i ] ;
119+ if ( colValues [ i ] !== null ) {
120+ filters [ attr ] = colValues [ i ] ;
121+ }
122+ }
123+ for ( const i of Object . keys ( rowAttrs || { } ) ) {
124+ const attr = rowAttrs [ i ] ;
125+ if ( rowValues [ i ] !== null ) {
126+ filters [ attr ] = rowValues [ i ] ;
127+ }
128+ }
129+ return e =>
130+ this . props . rendererOptions . table . clickCallback (
131+ e ,
132+ value ,
133+ filters ,
134+ pivotData
135+ ) ;
136+ }
137+ : null ;
138+
109139 return (
110140 < table className = "pvtTable" >
111141 < thead >
@@ -199,6 +229,10 @@ function makeRenderer(opts = {}) {
199229 < td
200230 className = "pvtVal"
201231 key = { `pvtVal${ i } -${ j } ` }
232+ onClick = {
233+ getClickHandler &&
234+ getClickHandler ( aggregator . value ( ) , rowKey , colKey )
235+ }
202236 style = { valueCellColors (
203237 rowKey ,
204238 colKey ,
@@ -211,6 +245,10 @@ function makeRenderer(opts = {}) {
211245 } ) }
212246 < td
213247 className = "pvtTotal"
248+ onClick = {
249+ getClickHandler &&
250+ getClickHandler ( totalAggregator . value ( ) , rowKey , [ null ] )
251+ }
214252 style = { colTotalColors ( totalAggregator . value ( ) ) }
215253 >
216254 { totalAggregator . format ( totalAggregator . value ( ) ) }
@@ -233,14 +271,24 @@ function makeRenderer(opts = {}) {
233271 < td
234272 className = "pvtTotal"
235273 key = { `total${ i } ` }
274+ onClick = {
275+ getClickHandler &&
276+ getClickHandler ( totalAggregator . value ( ) , [ null ] , colKey )
277+ }
236278 style = { rowTotalColors ( totalAggregator . value ( ) ) }
237279 >
238280 { totalAggregator . format ( totalAggregator . value ( ) ) }
239281 </ td >
240282 ) ;
241283 } ) }
242284
243- < td className = "pvtGrandTotal" >
285+ < td
286+ onClick = {
287+ getClickHandler &&
288+ getClickHandler ( grandTotalAggregator . value ( ) , [ null ] , [ null ] )
289+ }
290+ className = "pvtGrandTotal"
291+ >
244292 { grandTotalAggregator . format ( grandTotalAggregator . value ( ) ) }
245293 </ td >
246294 </ tr >
@@ -254,6 +302,7 @@ function makeRenderer(opts = {}) {
254302 TableRenderer . propTypes = PivotData . propTypes ;
255303 TableRenderer . defaultProps . tableColorScaleGenerator = redColorScaleGenerator ;
256304 TableRenderer . propTypes . tableColorScaleGenerator = PropTypes . func ;
305+ TableRenderer . propTypes . rendererOptions = PropTypes . object ;
257306 return TableRenderer ;
258307}
259308
0 commit comments