If you use TypeORM and MUI Data Grid server-side filter or server-side sorting this project can be helpful.
npm install typeorm-mui-query
const [queryOptions, setQueryOptions] = useState({
filterModel: {
items: [],
},
sortModel: [],
})
const handleSortModelChange: DataGridProProps['onSortModelChange'] = useCallback((sortModel) => {
setQueryOptions((currentState) => ({ ...currentState, sortModel }))
}, [])
const handleFilterModelChange: DataGridProProps['onFilterModelChange'] = useCallback(
(filterModel) => {
setQueryOptions((currentState) => ({ ...currentState, filterModel }))
},
[]
)
const query = new URLSearchParams({
...queryOptions,
sortModel: JSON.stringify(queryOptions.sortModel),
filterModel: JSON.stringify(queryOptions.filterModel),
})
const results = await API.get('default', `/example?${query.toString()}`, {})
import { handleQuery } from 'typeorm-mui-query'
handleQuery({ qb, queryStringParameters })
const results = await qb.getMany()