Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search result is reset when a rerender occur in the application with search and remote enabled. #1608

Closed
widdde opened this issue Sep 10, 2017 · 9 comments

Comments

@widdde
Copy link

widdde commented Sep 10, 2017

I'm using BootstrapTable with "search" option (search field in top right corner that search in every field in the table) enabled and remote enabled for cellEdit (remote(remoteObj) {remoteObj.cellEdit=true;}. As soon as a rerender occur in the application the table resets the search and all items will be shown again. The search textfield still contains the search string that was written.
I don't think this is the expected behavior. Shouldn't the table keep the filter even if a re-render, caused by calling setState, occur in the application? I have tracked it down to the remote method, as soon as I enabled "remote" in the table this behavior occurs, but not when it is disabled.

Any suggestions?

EDIT: I am using the latest (4.0.0) version of React Bootstrap Table.

@AllenFang
Copy link
Owner

HI @widdde, what's situation cause the rerender? after you saving the result of the cell editing?

@widdde
Copy link
Author

widdde commented Sep 13, 2017

Hi @AllenFang !
No, actually this happens when something in the view where the BootstrapTable is placed causing a state update, not really in the table itself.

To reproduce the "feature":

< BootstrapTable data={this.state.data} search remote={ this.remote } options={ {
onCellEdit: this.onCellEdit,} }><TableHeaderColumns... >< /BootstrapTable >

remote(remoteObj) {
remoteObj.cellEdit = true;
return remoteObj;
}

onCellEdit() {
Do something..
}

Create, for example, a div or a button or something that is updating the state on something on the page where you have the table..
< div onClick={() => this.onClick} >Click this< /div >

onClick() {
this.setState({message: "Changing the state in the component",})
}

If you have searched something in the search field in the table, this will reset the search and show all data in this.state.data again.. As soon as i put the pointer in the searchfield again, the search result is back and when pressing the div, or button and changing another state the search is reset again and so on..

Hope you understand :)

EDIT: Fixed the html tags that were missing by adding a space in the jsx tags.

@AllenFang
Copy link
Owner

sure, I can reproduce it now, i think it's a critical bug, I will fix ASAP, thanks

@widdde
Copy link
Author

widdde commented Sep 13, 2017

Thanks for fast response!
I found a workaround for this, by not enable remote but keep the onCellEdit: this.onCellEdit. This will still call the this.onCellEdit method even if remote is set to false. This doesnt reset the search but will still call the onCellEdit when edit a cell. Two separate things but now it works for me att the moment :)

@AllenFang
Copy link
Owner

@widdde bug fixed on v4.0.4 please check it again, thank you 👍

@widdde
Copy link
Author

widdde commented Sep 15, 2017 via email

@AllenFang
Copy link
Owner

hmm. actually, it's a bug anyway. but remote do effect on a lots of functionality.

@widdde
Copy link
Author

widdde commented Sep 18, 2017 via email

@canvural
Copy link

This still happens to me at v4.0.5

Search input is resetted when size per page list is changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants