简体   繁体   English

反应 ant 设计表的搜索过滤器错误

[英]Error on search filter for react ant design table

Table throws TypeError: Cannot read property 'toString' of undefined[object Object] whenever I am doing a search on the field.每当我在该字段上进行搜索时,表都会抛出TypeError: Cannot read property 'toString' of undefined[object Object] I've attached a code sample我附上了代码示例

Can anyone tell me what have I done wrong?谁能告诉我我做错了什么?

The error occurs when you have null data in your column. 当您的列中有空数据时,将发生错误。 For example, if one one of your rows is missing an age value and you attempt to search that column it will throw the error. 例如,如果您的某一行缺少年龄值,而您尝试搜索该列,则会抛出错误。 Unsure how to fix it. 不确定如何修复。

Yeah i faced same type of error, i fixed this issue.是的,我遇到了同样类型的错误,我解决了这个问题。

issue is:问题是:

{ onFilter: (value, record) => record[dataIndex].toString().toLowerCase().includes(value.toLowerCase()) }

After fixing the using if condition修复 using if 条件后

{ onFilter: (value, record) => { if (record[dataIndex]) return record[dataIndex].toString().toLowerCase().includes(value.toLowerCase()) } }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM