const [searchQuery, setSearchQuery] = useState("");
const [filteredItems, setFilteredItems] = useState(items);
<TextField
label="Search"
value={searchQuery}
onChange={(event) => setSearchQuery(event.target.value)}
/>
const handleSearch = (query) => {
const filteredData = items.filter((item) =>
item.name.toLowerCase().includes(query.toLowerCase())
);
setFilteredItems(filteredData);
};
useEffect(() => {
handleSearch(searchQuery);
}, [searchQuery]);
<DataGrid rows={filteredItems} columns={columns} />
This will allow the search feature to only filter the currently displayed results, rather than the entire dataset.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-25 01:12:08 +0000
Seen: 10 times
Last updated: May 25 '23
What is the name of the file containing the Cypress reporter results?
Is it possible to not get any results when using Strings.Instr or IndexOf to search for a substring?
How can I set values on a Map using more than one parameter from a nativeQuery?
Can a literal search be performed even after applying stemming?
What are the results of object detection using yolov5?