Support Conjunction (&&) as Search Mode
Currently, two very different search modes are supported:
- A very exclusive one, that accepts only rows with the exact
searchTextcontained as-is in any of their cells. (default) - A very inclusive one, that accepts all rows that contain at least one of the whitespace-separated terms in the
searchText. (multiColumnSearch: true)
One could argue whether "multiple columns" are any differentiation between these two cases, but that's not my point here. I merely want to point out that for some use cases the (default) option (1) is too strict and the alternative option (2) is not strict enough.
Therefore I propose introducing an additional strictSearch prop opening up the way for four different search modes, i.e. two more options.
I'll demonstrate the difference with a single row as example:
| Col1 | Col2 |
|---|---|
| A B | C |
Search modes and whether they would include the above row for the given searchText
| case | searchText |
strict && !multiColumn (existing option 1) |
!strict && !multiColumn |
strict && multiColumn |
!strict && multiColumn (existing option 2) |
|---|---|---|---|---|---|
| part of the content | "A" | ✅ | ✅ | ✅ | ✅ |
| whole content | "A B" | ✅ | ✅ | ✅ | ✅ |
| wrong order | "B A" | ❌ | ✅ | ✅ | ✅ |
| leading whitespace | " A" | ❌ | ✅ | ✅ | ✅ |
| trailing whitespace | "B " | ❌ | ✅ | ✅ | ✅ |
| not in one column | "B C" | ❌ | ❌ | ✅ | ✅ |
| partially contained | "A D" | ❌ | ❌ | ❌ | ✅ |
| not contained | "D" | ❌ | ❌ | ❌ | ❌ |
PR #1196 is implementing this. Please have a look. 😄
@CarstenWickner, thanks your proposal, I thinks it's a nice feature and I'll spend some time to review your PR. Thanks a lot :)
BTW, A awesome compared table 👍
I'm glad you like the idea. Additionally, I'd be happy to write some unit tests for it. Unfortunately there doesn't seem to be any unit test setup in this project and I was hesitant to just introduce one as part of this feature.
There seems to be at least the beginning of a jest setup with a __test__ folder. How about I just add jest as dev dependency and write some tests for the TableDataStore's _search() function being altered here?
As it's already complicated enough, I'd be more confident to have some test coverage and not just an example in the demo list.
Additionally, I'd be happy to write some unit tests for it. Unfortunately there doesn't seem to be any unit test setup in this project and I was hesitant to just introduce one as part of this feature.
Actually, this project is my first repo for practicing React.js about two year ago, so I even didn't write the test, you know just play with React(Free style)... But no idea why this repo become little popular. so if you grap code deeply, you will find the some components are very complicated and they need to being divided as to some sub component for React stateless principle so that it'll be easy to test..
Anyway, you can skip the testing, that is ok for this repo but not ok for software development 👍
Release at v3.2.0, thanks your hard work 👍