filterFormatted doesn't work if same dataField is used in more than one column
See original GitHub issueThe main search filter functionality doesn’t work when the same dataField is used twice. In this case, dataField=“locations” is being used twice because I am formatting the data differently afterwards for display and adding ‘filterFormatted’ to the table columns.
Any idea on how to make sure I can search filter properly both the ‘locations’ columns?
Below is the table and the dataFormat functions.
<BootstrapTable
data={this.state.chartData}
hover={true}
condensed={true}
pagination={true}
search
headerStyle={ { background: '#002699', color: '#ffffff' } }
multiColumnSearch
>
<TableHeaderColumn
dataField="id"
isKey={true}
width="50px"
dataFormat={ selectFormatter }
>Select</TableHeaderColumn>
<TableHeaderColumn
width="100px"
dataField="locations"
filterFormatted
dataFormat={ nameFormatter }
dataSort={true}
>Business Name</TableHeaderColumn>
<TableHeaderColumn
width="140px"
dataField="locations"
filterFormatted
dataFormat={ locationsFormatter }
dataSort={true}
>Address</TableHeaderColumn>
</BootstrapTable>
The dataFormatter functions the alter the two ‘locations’ columns
const locationsFormatter = (cell, row) => {
if (cell[0]) {
return `${cell[0].address} ${cell[0].city} ${cell[0].state}`;
} else {
return ' ';
}
};
const nameFormatter = (cell, row) => {
if (cell[0]) {
const businessName = `${cell[0].name}`;
console.log('businessName', businessName);
console.log('businessName', typeof(businessName));
return businessName;
} else {
return ' ';
}
};
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
5 Reasons why your Excel filter may not be working
1. Check that you have selected all of the data. If your data has empty rows and/or columns or if you are only...
Read more >Error while filtering data between two data card (Combobox)
Filter in businessunits data card (items) but I got error near = sign ... So, if we're using lookup columns, we must use...
Read more >ag-grid filter not working with formatted number values?
I use formatted numbers with currency values. Below is the columndef code: { headerName:"GBO", field: "GBO", width: 200, editable:true, ...
Read more >Table Header width and Table Body width mismatch and ...
1 ] **The header columns width do not match with their corresponding body columns width. It looks as if data of one column...
Read more >Formatting numbers, strings and currency values in ag-Grid
You'll see three pairs of columns, each pair consists of one unformatted column and a duplicate column using a value formatter. Let's go...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@AllenFang Yes, I preprocessed the data to appropriate format and fed it into the table so that I don’t have to use dataFormatter. It is not the most efficient way, but I am dealing with relatively small amount of data so it doesn’t affect performance.
Any update on this? Is this fixed in react-bootstrap-table 2? Thanks!