Substring Filter

Is there a way to search a filter and match all records including a sub-string, e.g. searching 703 would return the records UK703E and UK703A?
5 Replies
kapa.ai
kapa.ai11mo ago
Hi @G. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the extracts, there is a discussion related to filtering and the use of different filter operators in the context of the useTable hook within the refine framework. Specifically, a contributor expressed a desire to use a fixed operator like "contains" instead of "eq" for filtering, which aligns with your question about substring filtering. Here's the relevant part of the conversation:
**Comment by CONTRIBUTOR (0 upvotes, 0 downvotes)**:
So what's the best way to do it? What I want is to use a fixed operator, like "contains" rather than "eq" for the filter.
**Comment by CONTRIBUTOR (0 upvotes, 0 downvotes)**:
So what's the best way to do it? What I want is to use a fixed operator, like "contains" rather than "eq" for the filter.
This indicates an interest in achieving functionality similar to what you're asking for—filtering that matches records including a substring. However, the conversation also highlights that the useTable hook does not allow changing the filter operator dynamically, which would be necessary for switching between different types of substring matching (e.g., "contains", "starts with"). The contributor mentioned a workaround involving the use of initialFilter to set the operator initially but noted this does not allow for dynamic changes during runtime:
**Comment by CONTRIBUTOR (1 upvote, 0 downvotes)**:
You are right @omeraplak that giving the operator to `initialFilter` can change it - but just initially.
**Comment by CONTRIBUTOR (1 upvote, 0 downvotes)**:
You are right @omeraplak that giving the operator to `initialFilter` can change it - but just initially.
Furthermore, they discussed the possibility of achieving dynamic operator changes through a custom implementation or modification:
This is already possible by adding a select field or checkbox to `renderDropdownFilter` (or in an external filter component like the one you linked to), but the problem is `useTable` does not allow to change the filter operator dynamically (because it does not offer a method to do so). The change in #1375 is very simple but already versatile enough to achieve this behaviour.
This is already possible by adding a select field or checkbox to `renderDropdownFilter` (or in an external filter component like the one you linked to), but the problem is `useTable` does not allow to change the filter operator dynamically (because it does not offer a method to do so). The change in #1375 is very simple but already versatile enough to achieve this behaviour.
While this conversation does not provide a direct solution or code snippet for implementing a substring filter, it suggests that achieving this functionality might require custom modifications to the useTable hook or the use of initialFilter with a suitable operator, if available. For more detailed guidance or updates on this functionality, I recommend checking the refine documentation or the GitHub issue discussions directly, as they might have evolved since these extracts were provided. Unfortunately, without direct extracts showing the implementation of a "contains" filter or similar functionality, I cannot provide a specific code example or confirm its availability out-of-the-box in refine. For the latest information and examples, visiting the official refine documentation and GitHub repository could be beneficial: - Refine Documentation (https://refine.dev/docs/) - Refine GitHub Repository (https://github.com/refinedev/refine) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai11mo ago
<@140656141196722176> kapa.ai is still learning and improving, please let us know how it did by reacting below
xenophobic-harlequin
xenophobic-harlequinOP11mo ago
The following code: shows data for a second and then shows "no data"
xenophobic-harlequin
xenophobic-harlequinOP11mo ago
@kapa.ai
kapa.ai
kapa.ai11mo ago
Let me check the knowledge base for you. One moment! :books: Sorry @G, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?

Did you find this page helpful?