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

列表第一次渲染时,设置selectedRowKeys无效 #38

Closed
hi-otto opened this issue Jul 1, 2020 · 4 comments
Closed

列表第一次渲染时,设置selectedRowKeys无效 #38

hi-otto opened this issue Jul 1, 2020 · 4 comments

Comments

@hi-otto
Copy link

hi-otto commented Jul 1, 2020

复现地址:https://codesandbox.io/s/mystifying-torvalds-qrf8j?file=/index.js
尝试在列表渲染前,设置一些默认选中项,但是无效,列表状态依然都是未选中
image

@huguoliang1314
Copy link

在WILL_LIST_UPDATE生命周期内使用setRowSelection来设置默认项。

$(ListLifeCycleTypes.WILL_LIST_UPDATE).subscribe((payload) => {
console.log("WILL_LIST_UPDATE", payload);
const selectedRowKeys = actions
.getDataSource()
.map((v) => v.value)
.slice(0, 2);
console.log(selectedRowKeys);
// actions.setSelectionConfig({
// ids: selectedRowKeys,
// });
actions.setRowSelection({
ids: selectedRowKeys
})
});

@hi-otto
Copy link
Author

hi-otto commented Sep 29, 2020

在WILL_LIST_UPDATE生命周期内使用setRowSelection来设置默认项。

$(ListLifeCycleTypes.WILL_LIST_UPDATE).subscribe((payload) => {
console.log("WILL_LIST_UPDATE", payload);
const selectedRowKeys = actions
.getDataSource()
.map((v) => v.value)
.slice(0, 2);
console.log(selectedRowKeys);
// actions.setSelectionConfig({
// ids: selectedRowKeys,
// });
actions.setRowSelection({
ids: selectedRowKeys
})
});

依然不行,demo如下:
https://codesandbox.io/s/mystifying-torvalds-qrf8j?file=/index.js

@quirkyshop quirkyshop reopened this Sep 29, 2020
@quirkyshop
Copy link
Contributor

quirkyshop commented Sep 29, 2020

之前的版本修复的生命周期有问题,已复现,中午修复下

@quirkyshop
Copy link
Contributor

quirkyshop commented Oct 9, 2020

文档有误,实际字段应该是 ids

参考上面给出的示例,完整的参数类型是这样的

字段名 描述 类型
ids 选中id列表 Array<string
records 选中条目数 Array
primaryKey 主键, 默认值为id string
mode 总页面数 'single' or 'multiple'
getProps 设置筛选项属性 (record: any) => Object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants