React-bootstrap-table2: Feature request: row object in rowEvents

Created on 24 Jan 2018  路  8Comments  路  Source: react-bootstrap-table/react-bootstrap-table2

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)
  }
};
good first issue help wanted

Most helpful comment

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

All 8 comments

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

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.

@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

Also requesting this feature :)

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

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

Thanks a lot, Allen! Fantastic job!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cnav007 picture cnav007  路  4Comments

josefheld picture josefheld  路  3Comments

Randore picture Randore  路  3Comments

imtmh picture imtmh  路  3Comments

bogannathan picture bogannathan  路  4Comments