Sorting and filtering server-side #9
-
Hi, Is there a way to switch to controlled filtering (including different filter modes) and sorting, so it triggers the respective actions on api endpoints? Basically switching from client-side filtering / sorting to server-side? Is there any example for that maybe? Thanks a lot for the awesome work on this component :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Yes actually I want to write the docs on how to do that soon, but what you are looking for is the The last example on this page shows how you can do this, but I'll have more detailed examples soon! const [rows, setRows] = useState(() => data);
return (
<MaterialReactTable
columns={columns}
data={rows}
manualFiltering
enableColumnChangeMode={false}
onColumnFilterValueChanged={async({ column, event, filterValue }) => {
// put server side async call here
const filteredRows = data.filter((dataRow) =>
dataRow[column.id]
.toLowerCase()
.startsWith(filterValue.toLowerCase()),
);
setRows(filteredRows);
}}
/>
); You can do a similar thing with sorting, but I had not made an example of that yet |
Beta Was this translation helpful? Give feedback.
-
I have created an official example for manual server filtering, search, sorting, and pagination! |
Beta Was this translation helpful? Give feedback.
I have created an official example for manual server filtering, search, sorting, and pagination!
https://www.material-react-table.com/docs/examples/remote