Closed Grapedge closed 3 years ago
我也要开始做排序了,握抓。直观感觉可能是 protable的版本跟react的版本有点不匹配。
protable 的排序不是受控的,所以有点麻烦
在获取数据时,可以设个sort的初始值,假装获取的是已经排序的数据,然后前端点击倒序正序后的页面显示跟第一次渲染的结果相同
I have the same bug here, defaultsSort order is defined but requests ignores it.
+1 设置了默认排序有显示状态,第一次点击无法触发 request 方法,第二次点击可以正常触发
Is the fix coming? Created codesandbox with the bug: https://codesandbox.io/s/pro-table-bug-d8pms
@chenshuai2144 I am sorry, but I don't quite get it, this issue is about defaultSortOrder not passing to request, but https://github.com/ant-design/pro-components/issues/1581 is different. My chinese knowledge is very low, can you explain how these are related please?
@proxcentb to set a default value, use the property initialValue in ProColumnType.
@renanwilliam I'm sorry, I still don't get it... I just want defaultSortOrder to be passed to request, but setting defaultSortOrder for some column doesn't work. What should I do exactly?
Don't worry, I spent a lot of time on this too. Instead use defaultSortOrder property, just use initialValue property and it will works like expected.
@renanwilliam I tried to replace defaultSortOrder with InitialValue, but still no luck, can you please fork and edit this codesandbox so that sort order is passed to request? https://codesandbox.io/s/pro-table-bug-84qho
Hi @proxcentb,
Sorry, I mistook me with the defaultFilter
/ initialValue
options.
The defaultSortOrder
bug really exists, the workaround can be checked at https://codesandbox.io/s/pro-table-bug-forked-c4ezr?file=/src/index.tsx
Is not pretty but is a viable alternative
@renanwilliam I've been thinking about this workaround as well, but what if user doesn't want any sorting? In your example sort property will always be sent. I will try to find a different workaround, but nontheless, bug still persists and I don't believe it is a duplicate of https://github.com/ant-design/pro-components/issues/1581. Thank you for trying to help though 😃
@chenshuai2144 can we reopen this bug? Looks like the guys found out above that it really exists.
这还没解决呢怎么就close了?
I‘m use params filed to replace the sorter in the request function.store the sorter use useState hook. 我用params这个参数来代替request方法中的sorter参数。然后自己使用useState来存储sorter,在onChange中将sorter存在state里面
我在请求函数中使用params提交来替换排序 器。存储排序器使用useState hook。我用params这个参数来代替请求方法中的排序器参数。然后自己使用useState来存储排序器,在onChange中将排序器存在状态里面
这个onChange是在什么时候触发的呢可以看看相关代码吗?
🐛 bug 描述
表格列设置了
defaultSortOrder
属性,本地排序表现正常,但request
的参数sort
没有显示此排序项目。📷 复现步骤
见代码
🏞 期望结果
期望
sort
中可以获取到相应的排序信息以便远程排序。💻 复现代码
© 版本信息
🚑 其他信息
补充:当点击刷新按钮时表现仍然异常,但切换分页后就可以正常传递