question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

filterFormatted doesn't work if same dataField is used in more than one column

See original GitHub issue

The 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Andriy-Kulakcommented, Feb 8, 2017

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

0reactions
matoelorriagacommented, Sep 27, 2018

Any update on this? Is this fixed in react-bootstrap-table 2? Thanks!

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found