Open ghost opened 6 years ago
P.S. I've found that there is a way to do remote
table where I would have to provide all the functions for sorting and filtering, but I'd want to try to avoid that.
Any help?
@max-litv it's sorry for lately reply,
For your question, the problems like you said, because the dataField
. Currently, there's still a solution is remote
, remote
allow you to configure search
only for remote handling, check this example, configure remoteObj.search
as true will only enable search as remote mode.
BTW, you give a good point that many people will have different column which is not corresponding to specified field, like your case.
I'll handle this issue in react-bootstrap-table2
Hi Allen
Is there any update of this issue in react-bootstrap-table2 ?
I was able to solve using a Custom Search Component documented here https://react-bootstrap-table.github.io/react-bootstrap-table2/docs/basic-search.html#customize-search-component
Example
const CustomSearchComponent = (props) => {
let input;
const handleChange = (e) => {
return customAsyncSerachOnServer(input.value)
.then(result=> {
if(result!== null) //If a result was found change the search value to the id of the result to get single match
props.onSearch(result.id);
else //Use the default built in search logic and pass the value through
props.onSearch(input.value);
})
};
return (
<div>
<input
className="form-control"
ref={ n => input = n }
type="text"
style={{width: "15%"}}
placeholder="Search"
onChange={ handleChange }
/>
</div>
);
};`
I've read a lot of closed issues in similar search and filtering data, but can't make mine to work. Sorry for long post, but I want to make this as clear as possible.
ISSUE: When
searching
(main search on top), I'd likefilterValue
to be used on some columns. It does not work(at least in my case).What's complex on my end is that I have this type of data:
Here's how I display it(love this project, btw):
Searching works perfectly on simple data such as PID column.(shown on screenshot).
However, it does NOT work on URLs and Business columns.
Here are some of the snippets of my code: HTML:
NOTICE, on 3rd and 4th
TableHeaderColumn
I had to make customdataField
. Initially I had the both equal tolinks
, but my filtering did NOT work properly for both columns(only lastfilterValue
would be used). So I used custom names.JS:
.
So, when I use filters on URLs or Business, it works AWESOME. But when I try to search for the same values in main search these do not work. Any help?
My guess is that it's related to custom
dataField
names that I use.