Do people generally prefer strict search? I see that in Frappe all the searches are implemented to return documents that have the exact order of letters searched. I had multiple users tell me that their biggest pain was that they couldn’t find items. So for searching links, I have done an override to the called method. So now it searches like this:
For example:
I wanted to do the same for datatable column filters. But I noticed that it is all implemented in js node module. Is there a simple way to override this or should I contribute to datatable. And maybe we could add option to enable flexible search.
Since the filtering logic in frappe-datatable
is encapsulated in the JS module, the customization isn’t as straightforward as overriding a server-side controller or a Python method. However, here are a few practical options:
Option 1: Patch frappe-datatable
Locally (Not Recommended)
You can fork the frappe-datatable
repo, modify the column filtering logic (likely within data.js
or filter.js
), and bundle your own version. This works well but needs to be re-merged with every upgrade.
Option 2: Extend via Custom App
Create a custom app with Webpack or Vite for frontend assets, you could:
- Import
frappe-datatable
directly.
- Wrap the filtering function to implement fuzzy match logic (e.g., token-based search like
includesAllTokens(['john', 'doe'])
).
- Inject your own version into the datatable instantiation.
Option 3: Contribute to Frappe
This seems to be the most sustainable path. A configurable filter strategy perhaps via a filterMatchStrategy: 'strict' | 'tokens' | 'fuzzy'
option would be a great enhancement. You could keep strict as default for backward compatibility.
1 Like
Good idea on options to choose a strategy.
Just now sent a PR adds serbian translation and option to choose search type by ikslavok · Pull Request #209 · frappe/datatable · GitHub
So, if it gets accepted, there is now option to choose strategy like this.
filterMatchStrategy: 'strict' | 'tokens' | 'fuzzy'
strict means: exact order of search string
tokens means: all words must be included in any order, must be exact words
fuzzy: same as tokens, but can be parts of words
1 Like