react-bootstrap-table2 icon indicating copy to clipboard operation
react-bootstrap-table2 copied to clipboard

Feature request: row object in rowEvents

Open fuchsberger opened this issue 8 years ago • 8 comments

Would it be possible to make the row data object available on a rowEvent?

const rowEvents = {
  onClick: (event, row) => {
    console.log(`row ${row.id} was clicked.` )
  }
};

This would really help to avoid passing data as data-attributes down to the dom and then reading them through the event data.

Alternatively, i can also think of adding a flag to selectRow.onSelect that indicates whether the row was selected/deselected via the radio/checkbox or via click on row. this should only be available when the clickToSelect is enabled. an example could be:

const selectRow = {
  mode: 'checkbox',
  clickToSelect: true
  onSelect: (row, isSelect, rowIndex, rowClick) => {
    if(rowClick) // redirect to row.href
    else // default (select row)
  }
};

fuchsberger avatar Jan 24 '18 19:01 fuchsberger

@Sathras sure, I'll consider to add this feature :) . thanks!!

AllenFang avatar Jan 28 '18 12:01 AllenFang

Created PR and added storybook example: #187

For this:

Alternatively, i can also think of adding a flag to selectRow.onSelect that indicates whether the row was selected/deselected via the radio/checkbox or via click on row.

I think we already have the isSelect parameter. It will always remain true for single(radio) selection and for multiple(checkbox) selection will be true or false if selected or deselected respectively.

Thanks.

prajapati-parth avatar Jan 31 '18 02:01 prajapati-parth

@Sathras Hi, I have a quick question. if I understand correctly, without the feature you requested, there is no way to handle the row object with rowEvents right? For me, when I investigate 'e' parameter, it does not give me any productive data related to the selected row object Thanks a lot, :)

@AllenFang BTW, is this already supported? Thank you

Johnny-jober avatar Feb 08 '18 03:02 Johnny-jober

Also requesting this feature :)

brohlson avatar Feb 08 '18 05:02 brohlson

I also just ran into this. Cannot really use the component if I cannot do an action on the clicked row. Any workarounds?

galcivar avatar Feb 10 '18 03:02 galcivar

Hey all, this feature will be released in next week(2/14), thanks

AllenFang avatar Feb 10 '18 05:02 AllenFang

New Release: https://react-bootstrap-table.github.io/react-bootstrap-table2/blog/2018/02/14/version-bump.html

For this issue, check this > https://github.com/react-bootstrap-table/react-bootstrap-table2/blob/master/packages/react-bootstrap-table2-example/examples/rows/row-event.js#L23

Let me know if the problem still remain, thanks

AllenFang avatar Feb 14 '18 08:02 AllenFang

Thanks a lot, Allen! Fantastic job!

fuchsberger avatar Feb 14 '18 15:02 fuchsberger