How to customize expanded row that click on save button unselect the row
See original GitHub issueI have a customized table implementing with react-bootstrap-table. When I click the row, it expands with red highlight on the row. In the expanded row, I can edit fields and save accordingly. I want to close the expanded row on successful save, and remove the red color highlight. Currently, I can successfully save the record and collapse the expanded row, and here is the code: `class ClubsTable extends Component {
constructor(props) {
super(props);
}
render() {
const onRowSelect = ({_id}, isSelected) => {
// add to selectedRow array if selected
if (isSelected) {
this.props.selectClub(_id);
} else {
// delete from selectedRow array if unselected
this.props.unSelectClub(_id);
}
};
const options = {
expandRowBgColor: 'gray-lighter', // background color
sizePerPageList: [10, 15, 20, 50, 100], // Dropdown Options for rows per page
sizePerPage: 10,
sortName: 'club_name',
sortOrder: 'asc'
};
const selectRow = {
mode: 'checkbox', //radio or checkbox
className: 'clicked-row', // red color
clickToSelect: true,
onSelect: onRowSelect,
// selected: this.props.selectedClubs
};
const isExpandableRow = (row) => {
// console.log(this.props.closeExpandedRow);
return (row._id && (_.contains(this.props.selectedClubs, row._id)))
};
return (
<BootstrapTable
data={ this.props.clubs }
options={ options }
selectRow={ selectRow }
expandableRow={ isExpandableRow }
expandComponent={ (row) => {return (<ClubDetail club={ row }/>)} }
exportCSV
search
pagination>
<TableHeaderColumn dataField='club_name' isKey={ true } dataSort={ true }>Club
Name</TableHeaderColumn>
<TableHeaderColumn dataField='organization_name' dataSort={ true }>Organization
Name</TableHeaderColumn>
<TableHeaderColumn dataField='post_code' dataSort={ true }>Postal Code</TableHeaderColumn>
<TableHeaderColumn dataField='city' dataSort={ true }>City</TableHeaderColumn>
<TableHeaderColumn dataField='phone' dataSort={ true }>Phone Number</TableHeaderColumn>
<TableHeaderColumn dataField='contact_name' dataSort={ true }>Contact Name</TableHeaderColumn>
</BootstrapTable>
)
}
}`
However, I could not figure out how to also unselect the row so that the red color would be removed. I think the isSelected is not updated when I programmatically unselect the the row. And also, when I preselect rows with ‘selected: this.props.selectedClubs’, the row color will not be updated.
Any ideas?
Issue Analytics
- State:
- Created 7 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
Programatically close an expanded row with a button
Problem is that I cannot get a row to expand or close without clicking on it. For example : When I click on...
Read more >Select or Deselect Items on Row Click - Kendo UI Grid for jQuery
To deselect a row or select multiple rows by row clicking and without holding the Ctrl key, use the following approach. Edit Preview...
Read more >Documentation: DevExtreme - JavaScript Data Grid Methods
To expand a group row, call this method with an array (each member of which is a grouping value). To expand a master...
Read more >Work with a List, Record, or Table structured column ...
Expand a List structured column · To create a row for each list value, select Expand to New Rows. · To create a...
Read more >Child rows (show extra / detailed information)
on('click', 'td.dt-control', function () { var tr = $(this).closest('tr'); var row = table.row(tr); if ( ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
HI @ZhuQinglei, this is a similar issue that you can check it out.
First, I think you can not expand the row when click on row, because you dont enable
clickToExpand
inselectRow
props.Second, following is a example:
Third, it’s important, the above example can not collapse the row on click save button, I can only unselect the row, I think it’s a enhancement for expand row, user should have the ability to handle which row is expandable just like row selection. so I’ll do it quickly. As I mentioned in #927, expandable row is a new feature, so there’s must be a lots of thing I need to improve, so welcome to tell me if you have any concern.
BTW, you forgot to add
react-bootstrap-table
css(react-bootstrap-table-all.min.css
) into your repo, check the README, because I saw a gap between the header and body(Actually,react-bootstrap-table
construct by two different and separated table).Please let me know if you still have any trouble and I’ll improve expandable row as soon as possible. Thanks
@nikodonnell, I’ll add to docs ASAP and let me know if you got some trouble, thanks. but please open another issue and give more detail or example codes, thanks