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

Does a onSearch methode exist ? (like onFilter or onSort but for search)

Open Druwww opened this issue 6 years ago • 1 comments

Question I'm creating a single web app page witch use your lib to show a missions list. In the table, I have a button to zoom on a particular mission in a particular row. So the table component is erased each time I zoom on a mission. But, when I come back on the list (and the table), i would like to keep my previous searching parameters save.

For filter and sort, i used onFilter and onSort with the defaultData to save them in my main component state, but I can't find it for the SearchBar.

Doest a onSearch method exist that will be trigger each time the value in the input is updated ? If not, do you think it will be implemented in a upcoming feature ?

Screenshots A little screen shot to explain it : image I would like to update my state each time a input is done in the search area (the blue one)

codesandbox This is how look my table today. My goal is to display in the log the input value each time it change onSearch : (data) => console.log("Data : ", data) (sorry for the french string inside ^^)

<ToolkitProvider
                      keyField='id' 
                      data={ this.state.missions } 
                      columns={ this.state.tableColumn } 
                      defaultSortDirection="asc"
                      sort={ {
                        dataField: this.state.filter.field,
                        order: this.state.filter.order
                      }}
                      search={{ 
                        defaultSearch: this.state.search.global,
                        searchFormatted: true ,
                        onSearch : (data) => console.log("Data : ", data)
                      }}
                    >
                      {
                        props => (
                          <div>
                            <MySearch onChange={this.searchUpdate.bind(this)} { ...props.searchProps } />
                            <ClearSearchButton { ...props.searchProps } />
                            <hr />
                            <BootstrapTable
                              { ...props.baseProps }
                              pagination={ paginationFactory(this.state.paginationOption) } 
                              noDataIndication={this.state.missions.length <= 0 ? "Veuillez rafraichir le tableau avec le bouton au dessus" : "Aucun élément correspond à votre recherche"}
                              filter={ filterFactory() } 
                            />
                          </div>
                        )
                      }
                    </ToolkitProvider>

Thanks again for the lib and your time !

Druwww avatar Jun 29 '20 13:06 Druwww

Doest a onSearch method exist that will be trigger each time the value in the input is updated ? If not, do you think it will be implemented in a upcoming feature ?

So far we don't have onSearch, but have afterSearch. Because I'm busy recently so I can promise when I can implement this feature, so PR is welcome, thanks

AllenFang avatar Jul 12 '20 08:07 AllenFang