react-bootstrap-table
react-bootstrap-table copied to clipboard
When search something, data change but table not load it
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>
)
}
}
hello @chuchengcao, I've fix this problem on v0.9.9 :)
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>
)
}
}
Hi @chuchengcao , sorry for later response. I've fix this problem in v0.9.10. :)
Thank you. v0.9.10 fixed the problem, :)