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

[bug] searchFields 属性通过方法进行动态计算返回数组时,searchFiled 的选项只在点击 search 按钮后会自动把选择条件给清空,从而导致搜索功能无法使用 (注:不要用storybook来运行) #10

Closed
gdcnb opened this issue Oct 8, 2017 · 1 comment

Comments

@gdcnb
Copy link

gdcnb commented Oct 8, 2017

No description provided.

@gdcnb
Copy link
Author

gdcnb commented Oct 10, 2017

这个问题是 props 的 searchFields 传了一个 function 来动态返回数据,导致每次 render 时都重新送一个新的 searchFields 的数据给 dataTabel 从而导致上面的问题
正确的使用方法是要传一个固定的 searchFields 的数组给 dataTable
错误用法:
function getSearchField() {
return [
{
label: 'hello',
name: 'id',
type: 'input'
}
]
}
...
<DataTable
rowKey={record => record._id}
searchFields={getSearchField()}
/>

正确用法:
const searchFieldList = [
{
label: 'hello',
name: 'id',
type: 'input'
}
]
...
<DataTable
rowKey={record => record._id}
searchFields={searchFieldList}
/>

@gdcnb gdcnb closed this as completed Oct 10, 2017
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

1 participant