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.

Conditionally specify columns does not work

See original GitHub issue

I want conditionally specify which columns table will have. Usually I use ternary operator to hide something in the React by this does not work with React Bootstrap table. See example below.

export const BetDistributionTable = (props: BetDistributionTableProperties) => {
    const betType = props.showBetType
        ? <TableHeaderColumn width="200" dataField="betType" dataSort={true} isKey={true}>Тип ставки</TableHeaderColumn>
        : null;
    return <BootstrapTable data={props.data} bordered condensed hover trClassName=""
        options={{ defaultSortName: "date", defaultSortOrder: "desc" }}>
        <TableHeaderColumn width="200" dataField="date" dataSort={true} isKey={true}
            dataFormat={dateFormatter}>Date</TableHeaderColumn>
        {betType}
    </BootstrapTable>;
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
AllenFangcommented, May 15, 2017

ok, got it, but one more question, if you used hidden on TableHeaderColumn is helpful for you?

1reaction
kant2002commented, May 14, 2017

The problem not in the isKey or such. I think very often in React use following pattern

const header = showHeader ? <h1>Header</h1> : null
return <div>{header}</div>;

When I construct <TableHeaderColumn> objects like that React Bootstrap table does not like it.

I have table with 10 columns and couple of them could be shown/hidden as needed. I definitely could create workaround which will produce array of <TableHeaderColumn> components but think that RBT will benefit from having such simple way to dynamically create columns.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL Conditional column data return in a select statement
What I would like to do is have the select not display the Assignee name if the worksteam is internal. Instead to display...
Read more >
Add a conditional column (Power Query) - Microsoft Support
To open a query, locate one previously loaded from the Power Query Editor, select a cell in the data, and then select Query...
Read more >
Conditional column with does NOT include and OR criteria
Hello, what is the best way to set up a conditional column in the following scenario: COLUMN DESIRED OUTCOME (isolate all 'C') A....
Read more >
Conditional Column in Power BI using Power Query; You can ...
You can choose the value as the Output or Value to come from ... The problem of creating a conditional column with the...
Read more >
Conditionally allow column edits (Editable_If) - AppSheet Help
By administrators or specific users, but not others. · When another column has a specific value. · When adding a new row, but...
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