Select Filter template given in the website not working. TypeError: Cannot read property 'value' of undefined
//Here is my array on objects which denotes my column titles.
const selectOptionsArr = [
{
value: 0,
label: "Best Seller"
},
{
value: 1,
label: "Evergreen"
},
{
value: 2,
label: "Old Category-No recent demand"
},
{
value: 3,
label: "New Category"
}
];
//Here I am tryin to put the filter function according to the given template.
[..., dataField: "seg",
text: "Segment",
sort: true,
formatter: cell =>
selectOptionsArr.filter(opt => opt.value === cell)[0].label|| "",
filter: selectFilter({
options: selectOptionsArr
})
}
];
//Here I am applying the filter:
<BootstrapTable
keyField="id"
data={rowData}
columns={columns}
defaultSorted={defaultSorted}
pagination={paginationFactory()}
filter={filterFactory()}
striped
hover
condensed
/>
//Throws this error:
TypeError: Cannot read property 'label' of undefined
formatter
C:/Users/Desktop/data-extraction/e-commerce-data/src/table/BootTable.js:79
76 | dataField: "seg",
77 | text: "Segment",
78 | sort: true,
> 79 | formatter: cell =>
| ^ 80 | selectOptionsArr.filter(opt => opt.value === cell)[0].label|| "",
81 | filter: selectFilter({
82 | options: selectOptionsArr
Please look into the matter.
@cssher, did you find out the solutions for this?
Same issue, been searching for hours. As soon as I put any filter on a column, I get the error (where 'value' = name of column)
Figured it out with the help of the examples https://github.com/react-bootstrap-table/react-bootstrap-table2/tree/master/packages/react-bootstrap-table2-example/examples/column-filter and another issue https://github.com/react-bootstrap-table/react-bootstrap-table2/issues/1345
I was also using ToolkitProvider with the same columns property which was the one actually getting confused by the filtering. Hope this helps someone