I'm trying to set property on reselection change.but this.setState() throws error . Even I have binded onselectchange in constructor.
EDIT:when I tried to select all the rows from checkbox in column header it calls allSelectedRows() .here I'm getting count but its not setting
rowSelection = {
onChange: this.onSelectchange,
onSelectAll: (selected, selectedRows, changeRows) => {
console.log(selected, selectedRows, changeRows);
this.allRowsSelected(selected, selectedRows, changeRows);
},
};
constructor(props) {
super(props);
this.state = {
selectedRowKeys: []
}
this.onSelectchange= this.onSelectchange.bind(this);
}
allRowsSelected(selected, selectedRows, changeRows) {
this.setState({ selectedRowKeys: selectedRows.length });
console.log(this.state.selectedRowKeys.length);
}
onSelectchange(record){
console.log(record);
console.log(this.rowSelection);
this.setState({ selectedRowKeys: record });
}
render(){
return(
<Table
rowKey={data._id}
columns={this.columns1}
rowSelection={this.rowSelection}
expandedRowRender={(record, index, indent, expanded) =>
this.expanding(record, expanded)
}
onExpand={this.onExpand}
dataSource={data} />
)
}