Skip to content
This repository has been archived by the owner on Jan 15, 2022. It is now read-only.

provide ability to define onClick callback from table without explicitly defining children #125

Open
jlgerber opened this issue Mar 4, 2015 · 10 comments

Comments

@jlgerber
Copy link

jlgerber commented Mar 4, 2015

I don't see any documentation for this, but I do see a click callback on the reactable.td element. It would be great if we could define an onClick which propagates down to the individual td elements without having to explicitly supply children (ie an onClick on the actual table component, wherein I just supply data

<reactable data={ mydata } onClick={this.tableCellClicked}...

@irium
Copy link

irium commented Apr 2, 2015

+1 on this. Also it will be very useful to have onRowClick too.

@anyong
Copy link

anyong commented Apr 27, 2015

Anybody made progress on this yet before I start to write it?

@glittershark
Copy link
Owner

@anyong nobody as far as I know. Let's call the event handlers themselves onTrClick and onTdClick

@idevchew
Copy link

Question - I noticed that the Td cell has a onClick callback which is assigned to handleClick at init,
When I try to pass handleClick={this.myClick} from a parent node, the myClick is not passed at all although the handleClick is being called. It seems that this is being filtered out?

I am working around this as follows

var tdEvent = new CustomEvent( 'ReactableCellEvent' , {
detail: {
cellid : e.currentTarget.id,
celldata : this.props
},
bubbles: true,
cancelable: true
});
this.getDOMNode().dispatchEvent(tdEvent );

And catching at the parent node with
this.getDOMNode().addEventListener('ReactableCellEvent', this.doCell )

And adding the same for the the Tr class

However would love to have a proper onTrClick/OnTdClick though

otherwise GREAT JOB!!

@mlucool
Copy link

mlucool commented Dec 7, 2015

👍

@cklab
Copy link
Contributor

cklab commented Mar 2, 2016

@glittershark As a related side question/discussion: any particular reason for calling the click handler handleClick instead of sticking with the expected onClick?

@felizuno
Copy link

felizuno commented Mar 8, 2016

@anyong @idevchew do either of you have pull requests to add this functionality, or does somebody else need to take it up?

@glittershark
Copy link
Owner

@cklab it's mostly historical at this point. I would actually prefer to move all event handlers to on... and deprecate the handle... ones

@hdrdavies
Copy link

hdrdavies commented Aug 19, 2016

@glittershark is there a onTrClick as mentioned above?

p.s. this is incredibly awesome module 😄

@tvilon
Copy link

tvilon commented Feb 16, 2017

Here is my take on adding onRowClick: #362

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants