react-bootstrap-table icon indicating copy to clipboard operation
react-bootstrap-table copied to clipboard

When search something, data change but table not load it

Open chuchengcao opened this issue 11 years ago • 4 comments

Type "sdf" in the search input, click the change-data button, data not change.

class TestPage extends React.Component{
    constructor(){
        super();
        this.state = {dataSet:[
            {"objectName":"sdfsdfsdf33","userId":"cc","perms":["READ","WRITE"],"id":1}
        ]
        }
    }

    render (){
        console.log("this.state.dataSet", this.state.dataSet);
        return (
                    <div className='maxw80 ma'>
                        <BootstrapTable data={this.state.dataSet}
                                        striped={true} hover={true} condensed={false} search={true} pagination={true}>
                            <TableHeaderColumn className='clgrey' dataField="id" isKey={true} dataAlign="center"
                                               dataSort={true}>#</TableHeaderColumn>
                            <TableHeaderColumn dataField="objectName" dataSort={true}>name</TableHeaderColumn>
                            <TableHeaderColumn dataField="userId" dataSort={true}>userName</TableHeaderColumn>
                            <TableHeaderColumn dataField="perms" dataSort={true}
                                               dataFormat={(cell, row)=>(<span>{cell.toString()}</span>)}>
                                auth
                            </TableHeaderColumn>
                            <TableHeaderColumn dataField="id">
                                op
                            </TableHeaderColumn>
                        </BootstrapTable>
                        <button onClick={function(){this.setState({dataSet:[{"objectName":"newdata","userId":"all","perms":["READ"],"id":5}]})}.bind(this)}>change-data</button>
                    </div>
        )
    }
}

chuchengcao avatar Aug 19 '15 06:08 chuchengcao

hello @chuchengcao, I've fix this problem on v0.9.9 :)

AllenFang avatar Aug 19 '15 13:08 AllenFang

hello @AllenFang , v0.9.9 still has some problem. The data updated but the result is not filtered by the search string. Look for this example, type 'sdf' -> change-data -> expect the table shows result which only contain 'sdf' string according to the search, but the table shows all table data.

class TestPage extends React.Component{
    constructor(){
        super();
        this.state = {dataSet:[
            {"objectName":"sdfsdfsdf33","userId":"cc","perms":["READ","WRITE"],"id":1},
            {"objectName":"3333","userId":"cc","perms":["READ","WRITE"],"id":2},
            {"objectName":"4444sdf","userId":"cc","perms":["READ","WRITE"],"id":3}
        ]
        }
    }

    _onChange(){
        this.setState({dataSet:[
            {"objectName":"newdata","userId":"all","perms":["READ"],"id":1},
            {"objectName":"3333","userId":"cc","perms":["READ","WRITE"],"id":2},
            {"objectName":"4444sdf","userId":"cc","perms":["READ","WRITE"],"id":3}]
        })
    }

    render (){
        console.log("this.state.dataSet", this.state.dataSet);
        return (
            <div className='maxw80 ma'>
                <BootstrapTable data={this.state.dataSet}
                                striped={true} hover={true} condensed={false} search={true} pagination={true}>
                    <TableHeaderColumn className='clgrey' dataField="id" isKey={true} dataAlign="center"
                                       dataSort={true}>#</TableHeaderColumn>
                    <TableHeaderColumn dataField="objectName" dataSort={true}>name</TableHeaderColumn>
                    <TableHeaderColumn dataField="userId" dataSort={true}>userName</TableHeaderColumn>
                    <TableHeaderColumn dataField="perms" dataSort={true}
                                       dataFormat={(cell, row)=>(<span>{cell.toString()}</span>)}>
                        auth
                    </TableHeaderColumn>
                    <TableHeaderColumn dataField="id">
                        op
                    </TableHeaderColumn>
                </BootstrapTable>
                <button onClick={this._onChange.bind(this)}>change-data</button>
            </div>
        )
    }
}

chuchengcao avatar Aug 20 '15 02:08 chuchengcao

Hi @chuchengcao , sorry for later response. I've fix this problem in v0.9.10. :)

AllenFang avatar Aug 24 '15 15:08 AllenFang

Thank you. v0.9.10 fixed the problem, :)

chuchengcao avatar Aug 26 '15 04:08 chuchengcao