Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question:使用内部封装的vbenTable处理后端排序,表格更新后vxe sort的图标不高亮? #5081

Closed
5 tasks done
fiorayang opened this issue Dec 9, 2024 · 4 comments

Comments

@fiorayang
Copy link

Version

Vben Admin V5

Describe the bug?

翻阅了vxe的文档,没有得到较好的答案。这里是需要自己去维护sort的状态吗?但是并没有找到更新sort状态的方法。尝试使用sortConfig.defaultSort 去更新状态, 每次需要强制重新渲染表格才生效,且卡顿明显,应该不是正确的方案。请问这种情况如何处理呢?

Reproduction

const gridEvents = { sortChange: async (sort) => { sortParams[${sort.field}Sort] = sort.order === 'desc'; } };

System Info

System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 119.33 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.0.0 - /usr/local/bin/node
    npm: 10.2.0 - /usr/local/bin/npm
    pnpm: 9.14.4 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 131.0.6778.109
    Safari: 17.5

Relevant log output

No response

Validations

@fiorayang fiorayang changed the title 提问Issue:使用内部封装的vbenTable处理后端排序,表格更新后vxe sort的图标不高亮? Question:使用内部封装的vbenTable处理后端排序,表格更新后vxe sort的图标不高亮? Dec 9, 2024
@mynetfan
Copy link
Collaborator

mynetfan commented Dec 9, 2024

查阅vxeTable文档,默认情况下,刷新按钮调用的是reload,这会重置排序、筛选以及当前页数等信息。如果你只需要刷新,配置数据里将toolbarConfig的refresh.code配置为query

@mynetfan mynetfan closed this as completed Dec 9, 2024
@fiorayang
Copy link
Author

我这边尝试了2种方式。
1: 配置sortChange 通过 gridApi?.query()触发后端排序;
2: 配置proxyConfig.sort 直接在ajax的query函数中加入后端排序逻辑
但是数据回来了以后高亮均被重置,可以观察到点击后本是高亮的,数据一刷新就被重置了

@fiorayang
Copy link
Author

找到问题了 是因为我每次查询都要动态更新列 导致状态被重置了

@fiorayang
Copy link
Author

fiorayang commented Dec 10, 2024

目前我这边每次发起表格数据的请求都要动态的构造表格列gridApi.setGridOptions,一旦columns被更新,选中状态就被重置了。vxe我看完了也没发现可以手动控制sort状态的API。不知道对于这种情况大佬这边有什么解决办法吗? @mynetfan

@github-actions github-actions bot locked and limited conversation to collaborators Dec 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants