我正在尝试在 SectionList 中构建搜索功能。我在“数据”(第二个字段)内搜索,而不是在“标题”内搜索,但我无法使其工作。
我的数据是关于公寓的单位/居民详细信息 -
sectiondata =
[{"title":"GROUND FLOOR",
"data":[
{"id":"48","res_type":"owner","user_name":"Ashwani","flat_id":"1","flat_name":"001","floor_no":"GROUND FLOOR","floor_int":"0","signal_player_id":"aa","user_phone":"98855550"},
{"id":"49","res_type":"owner","user_name":"Rahul","flat_id":"2","flat_name":"002","floor_no":"GROUND FLOOR","floor_int":"0","signal_player_id":"aa","user_phone":"999999"}
]
}]
我正在尝试这样的事情,但它不起作用。
searchFilterFunction = (text) => {
let search = text.toLowerCase();
this.setState({
check: this.state.sectiondata.filter(
obj => obj.data['flat_name'].toLowerCase().includes(search))
});
}
如何根据名称过滤数据库?请在这里提供帮助。谢谢。