简体   繁体   中英

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. 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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