ProTable组件下rowSelection属性下的onChange是否可以通过不交互的方式触发 #9213
Unanswered
kelisiWu123
asked this question in
Q&A
Replies: 1 comment 1 reply
-
可以,ProTable 的 rowSelection.onChange 可以通过编程方式触发,不一定要用户交互。你只需要通过受控方式更新 selectedRowKeys(比如 setSelectedRowKeys),或者使用 actionRef.current.clearSelected() 清空选择项,onChange 就会被调用。例如: const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const rowSelection = {
selectedRowKeys,
onChange: (keys, rows) => {
setSelectedRowKeys(keys);
// 这里会响应触发
},
};
// 例如在某个按钮点击时清空选择
const clearSelection = () => setSelectedRowKeys([]);
// 或者使用 actionRef.current.clearSelected()
<ProTable rowSelection={rowSelection} actionRef={actionRef} /> 只要 selectedRowKeys 发生变化,onChange 就会被触发,无需用户操作。参考 官方文档 To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
如题
Beta Was this translation helpful? Give feedback.
All reactions