-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
官网组件demo的Table->useTable bug #3445
Comments
目前发现是因为加了showTableSetting: true,并且rowSelection没有自己定义onselect等参数,就会触发不了,把showTableSetting改为false就正常了 |
拿 src\views\demo\table\FixedColumn.vue 测试 给 selectedRowKeys 一个值 import type { Key } from 'ant-design-vue/lib/table/interface';
// ...
const keys: Key[] = [];
const [registerTable] = useTable({
title: 'TableAction组件及固定列示例',
api: demoListApi,
columns: columns,
// rowSelection: { type: 'checkbox' },
rowSelection: { type: 'checkbox', selectedRowKeys: keys },
bordered: true,
actionColumn: {
width: 160,
title: 'Action',
dataIndex: 'action',
},
showTableSetting: false,
}); 无需 showTableSetting 为 true,也可以重现。 showTableSetting 的 ColumnSetting 有以下代码,导致一样的问题: table.setProps({
rowSelection: showRowSelection
? {
...defaultRowSelection, // 这里来源于 getRowSelection,包含 selectedRowKeys
fixed: true,
}
: undefined,
}); 根据 https://antdv.com/components/table-cn#api 说明 只是现在由 useRowSelection 管理起来了,除非按原 ant table 自行控制onChange等事件,否则 只设置selectedRowKeys就失效了。 |
@zzc0217 稍后提个pr,避免 ColumnSetting 影响 selectedRowKeys,暂时可以除去这个影响。 |
更正一下,无法自行控制selectedRowKeys,需要通过 useRowSelection 的方法控制 selectedRowKey,例如默认选中某几项,就需要用 useRowSelection 的 setSelectedRowKeys。 |
好的,感谢! |
有个疑问,为什么这里会影响到useRowSelection 的管理select状态出问题呢? |
@zzc0217 我看是useRowSelection接管了selectedRowKeys,而 BasicTable 又依赖 useRowSelection,官方说的,需要更细节的体验,要么优化组件、要么自己实现。useRowSelection 实现了跨分页 selection,其它问题暂时没发现,用它的 method 也算可以满足情况。 |
table.setProps({ |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days |
描述 Bug
https://vben.vvbin.cn/#/comp/table/useTable,表格的checkbox选择不了
复现 Bug
点击checkbox以外的当前行可以勾选,但是点击checkbox以后就会选择不了任何行
系统信息
The text was updated successfully, but these errors were encountered: