user8779054
user8779054

Reputation: 183

onRowClicked for react-datatable

onMeetingTitleClick is working when i use onClick but it only works for that specific column.

I'm trying to get it working for the entire row using onRowClicked but i don t think i'm doing it right. Any ideas?

const MeetingsTable = ({ meetings, onMeetingTitleClick }) => {
  ...

  const columns = [
    {
      name: 'Title',
      cell: row => (
        <div data-tag="allowRowEvents">
          <div aria-hidden="true" onClick={e => onMeetingTitleClick(e, row.id)}>
            {row.name}
          </div>
        </div>
      ),
    },
  ];

  const onRowClicked = () => (result.map(result => (e => onMeetingTitleClick(e, result.id))));

  return (
    <DataTable
      columns={columns}
      data={result}
      onRowClicked={onRowClicked}
    />
  );

... Omitted other values

Reference lib: https://github.com/jbetancur/react-data-table-component

Upvotes: 3

Views: 5689

Answers (1)

user8779054
user8779054

Reputation: 183

Managed to complete this by using the following

const onRowClicked = (row, event) => { onMeetingTitleClick(event, row.id); };

https://github.com/jbetancur/react-data-table-component#readme

Upvotes: 3

Related Questions