initialValues empty in serachFormProps with syncWithLocation set to True
Hi, I am setting
syncWithLocation
to true for useTable from Antd, the initialValues
in searchFormProps is empty, but I am expecting the previously used value to be present there. Any help would be appreciated. Thanks7 Replies
Hey @mking9999 ,
Glad to see you again! 👊 I hope all is well in your life ⭐
I think it makes sense! We do this manually. You think this should be automatic, right?
https://example.admin.refine.dev/orders?pageSize=10¤t=1&filters[0][field]=q&filters[0][operator]=eq&filters[0][value]=test&filters[1][field]=status.text&filters[1][operator]=in&filters[1][value][0]=Pending
https://github.com/pankod/refine/blob/next/examples/fineFoods/admin/antd/src/pages/orders/list.tsx#L292
metropolitan-bronze•3y ago
I am doing really good, thanks to Refine making my life easier, hope you are doing good as well 😄
yes it would be really convenient if this could be done automatically
Thanks! Could you create a feature request? (https://github.com/pankod/refine/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=%5BFEAT%5D) I'm sure there will be a community member who wants to do it at the Hacktoberfest (https://hacktoberfest.com/) event 🚀
metropolitan-bronze•3y ago
done, thank you
Thank you! Don't forget to support us by giving stars hehe 🤣
typical-coral•2y ago
Hey @Omer , I noticed that the Issue created from this wasn't resolved but closed due to staleness. Issue link: https://github.com/refinedev/refine/issues/2624
I'm trying to implement what you did inside of https://github.com/refinedev/refine/blob/next/examples/finefoods-antd/src/pages/orders/list.tsx#L57 using the initialValues Prop as done here https://github.com/refinedev/refine/blob/next/examples/finefoods-antd/src/pages/orders/list.tsx#L308 but I can't get it to work. Apart from this stuff, is there anything else to remember or take care of? The documentation could be improved in that regard, as this is pretty default behavior IMHO.
Link to the docs: https://refine.dev/docs/api-reference/antd/hooks/table/useTable/#search
Got it!
You have to pass the operator of the filter that you want to display like:
getDefaultFilter('name', filters, 'contains')
This seems to me like a flaw inside of getDefaultFilter
.
Plus the Naming of the function should rather be getDefaultFilterValue
🤔 .Definitely a much better naming! Would you like to create a PR? 👀