Comments (10)
Yep, it's a good feature for row selection, I'll add this feature in recently, but need some times :))
from react-bootstrap-table.
Great thanks, I'll look forward to it!
from react-bootstrap-table.
This issue has been solved on PR#18
from react-bootstrap-table.
The committed solution for this issue only solves part of the problem for me. In my case, I need to be able to programmatically select a given row, or at a minimum have the component respect new props when it is re-rendered. The current solution only allows setting the default selected row when the component is first mounted, which isn't so flexible. (also see #19 ).
I've made some modifications and have this working in my dev environment - it causes new props to always set the desired row to the selected state. This seems to be working fine for me, but there might be a better way to do it. Unfortunately, I'm not familiar enough with git to start a pull request (maybe when I have more time), but the change is pretty simple:
This is what the top of TableBody.js looks like in my dev:
function TableBody(props) {
_classCallCheck(this, TableBody);
_get(Object.getPrototypeOf(TableBody.prototype), "constructor", this).call(this, props);
this._setSelectedRowByProps(props);
this._attachRowSelectFunc();
this.editing = false;
}
_inherits(TableBody, _React$Component);
_createClass(TableBody, {
componentDidUpdate: {
value: function componentDidUpdate(prevProps, prevState) {
this._attachRowSelectFunc();
}
},
componentWillReceiveProps: {
value: function componentWillReceiveProps(newProps) {
this._setSelectedRowByProps(newProps);
}
},
_setSelectedRowByProps: {
value: function _setSelectedRowByProps(props) {
var selected = props.selectRow.selected || [];
if (props.selectRow.mode === Const.ROW_SELECT_SINGLE) {
//if row selection is single, just pick the first item in 'selected'
selected = selected.length > 0 ? [selected[0]] : [];
}
this.state = {
currEditCell: null,
selectedRowKey: selected
};
}
},
Hope this helps!
from react-bootstrap-table.
I understand what you means, I'll spend some time to design it.
from react-bootstrap-table.
Ok great...also a new requirement has emerged on my project, and it would be very convenient to be able un-select a row from an external module without building in another re-render() cycle. Maybe a statics method on BootstrapTable would be useful(?)
from react-bootstrap-table.
I considered a statics method on some class before but there's some problem. Maybe I will re-think about that.
from react-bootstrap-table.
hi @stephenrs I've tried a lot of method for this requirement, include static or instance method. But there's no way to complete. Currently, I use componentWillReceiveProps
to achieve requirement but you need to assign the new selected value and re-render table, you can see the detail on #19
from react-bootstrap-table.
About the dynamic select or unselect feature, I've released on v0.9.5 :)
from react-bootstrap-table.
I am going to add the selected option in the selectRowProp
.
As a result, I have made the code below:
selectRowProp = { mode: 'radio', bgColor: '#e9ecef', clickToSelect: true, hideSelectColumn: true, selected: this.props.vehicles[0] && [this.props.vehicles[0].vin], onSelect: (row) => this.onRowSelect(row), }
As you can see, it will take some time to get props values. So currently selected is the empty or null value.
How can I fix it?
from react-bootstrap-table.
Related Issues (20)
- Read only on editable table for a field, but insert it in insertmodal HOT 1
- Sort icon not visible when text overflows in th
- Select All checkbox customization (Display any other icon instead of checkbox) HOT 2
- CellEdit is not working in firefox.
- Not showing Table border Tried Everything of Scripts importing CSS of bootstrap but still
- Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code.
- Select All doesn't persist across pages. HOT 1
- Not compatible with React 17+ HOT 6
- How to hide/show checkbox on particular rows in react bootstrap table next
- React Hooks, state is reseting to initial state when called onChange is called inside Formatter
- Expanding one row updating the value of all the expanded rows with the latest value
- How to get value of column selectFilter with deprecated react-boot-strap-table
- React Bootstrap Table - Iterate over an array of Objects for Datafield
- BootstrapTable is not reloading data when row checkbox checked or unchecked in ReactJS
- Error when search on page 2/3/4/5 etc
- Can't run the examples using gulp
- How can I delete/disable the "Expand All - Collapse All" button in the table header?
- Dynamic TableHeaderColumns with search and exportToCSV props doesn't work in BootstrapTable
- How can i use navigate pages using row ?
- React-data-table Component header alone is overlapping when the model/Pop us is enabled, HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-bootstrap-table.