0

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} />
    )
}

1 Answer 1

2

Can you please update your code as below one

rowSelection = {
    onChange: (record)=> this.onSelectchange(record),
};

I am not sure but I guess this will work for you! Let me know if not working.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.