React-bootstrap-table2: Selecting a single rows selects all rows

Created on 31 Mar 2018  路  10Comments  路  Source: react-bootstrap-table/react-bootstrap-table2

Hi I am trying to select a row, but every row gets selected.

I am using this code.

export const selectRow = {
mode: 'checkbox',
onSelect: (row, isSelect, rowIndex) => {
console.log("row", row);
console.log("isSelect", isSelect);
console.log("rowIndex", rowIndex);
}
};

I am importing the method in my parent and passing it as props to the table.

Please help. Any idea to debug why this is happening?

Most helpful comment

@eveseli-ritech make sure that in all your rows, the TableHeaderColumn which holds the value of key property (with isKey attribute), is not same. If this value is same, then selecting on one will select all of them.

All 10 comments

@a2441918 I can't reproduce this issue in newest version: check online demo

What version you used and would you please give me more information? thanks!!

I use version 0.1.5.

This is the function.
export const selectRow = {
mode: 'checkbox',
onSelect: (row, isSelect, rowIndex) => {
console.log("row", row);
console.log("isSelect", isSelect);
console.log("rowIndex", rowIndex);
}
};

This is my parent.
import {selectRow} from "../../components/DataTable/selectRow";

<DataTable
    keyField={ 'app_id' }
    columns={ this.child.columns }
    data={ this.props.data }
    totalRows={ this.props.totalRows }
    placeholder={ 'Application ID' }
    showStatus={ false }
    showClassification={ false }
    selectRow={ selectRow }
/>

This is the child.

<BootstrapTable
    keyField={ this.props.keyField }
    data={ this.props.data }
    columns={ this.props.columns }
    rowStyle={ centeredStyle }
    rowClasses={ this.props.rowClasses }
    striped
    hover
    condensed
    bordered={ this.props.bordered }
    noDataIndication={ indication }
    selectRow={ this.props.selectRow }
/>

When I select one row every row gets selected but console.log(row) gives me only the first row data and not the one I select.

I upgraded to the latest version. Removed my node modules and reinstalled them. Even tried passing in the object directly to the table and still the same issue.

@a2441918 give me a repo I can help to check but please remember show me how to setup your repo, thanks

Close it due to no response since from one month ago

I'm having the same issue. Any solution to this problem? Thanks in advance.

@eveseli-ritech please share how to reproduce. thanks

@eveseli-ritech make sure that in all your rows, the TableHeaderColumn which holds the value of key property (with isKey attribute), is not same. If this value is same, then selecting on one will select all of them.

@eveseli-ritech make sure that in all your rows, the TableHeaderColumn which holds the value of key property (with isKey attribute), is not same. If this value is same, then selecting on one will select all of them.

Thank you! I was just having the same issue but after reading your comment i realized there was no key column assigned in my table. Works like a charm.

What are these isKey or TableHeaderColumn values? They're not in the documentation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sudravi picture sudravi  路  3Comments

bogannathan picture bogannathan  路  4Comments

primakashi picture primakashi  路  3Comments

kamarajuPrathi picture kamarajuPrathi  路  4Comments

imtmh picture imtmh  路  3Comments