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.

Dynamically generated columns

See original GitHub issue

Do you know of a way to dynamically generate columns? I have something like this in mind (inside the render method):

const columns = ["name", "description", "age"];
return (
    <BootstrapTable data={someData}>
        <TableHeaderColumn isKey dataField="id">id</TableHeaderColumn>
        {columns.map(column => 
            <TableHeaderColumn dataField={column}>{column}</TableHeaderColumn>
        )}
    </BootstrapTable>
)

This seems like it would be a very efficient way of producing tables when you don’t know the columns ahead of time. When I try to do this however, if receive this error:

react-bootstrap-table.min.js?3226:6 Uncaught TypeError: Cannot read property 'children' of undefined

This makes me think that react-bootstrap-table might not be implemented in such a way that it supports this. I just wanted to see your thoughts.

Thanks for an awesome tool!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:24 (4 by maintainers)

github_iconTop GitHub Comments

11reactions
AllenFangcommented, May 12, 2016

HI, try following way:

return (
    <BootstrapTable data={someData} keyField='id'>
        {columns.map(column => 
            <TableHeaderColumn dataField={column}>{column}</TableHeaderColumn>
        )}
    </BootstrapTable>
)
4reactions
tylerjryancommented, May 12, 2016

Ah I see. The problem is trying to create one column manually and the rest in the map. When all of them are created in the map, it works great. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamically create columns sql - Stack Overflow
You will want to use a PIVOT function for this. If you have a known number of columns, then you can hard-code the...
Read more >
Solved: Re: (Table) Add dynamically generated columns (fro...
(Table) Add dynamically generated columns (from field values) onto pre-existing columns ; CartridgeType, Cartridge, SVP:A-1 ; User, Alpha, 1.4.
Read more >
Creating Dynamic Columns | Power Query Challenge - YouTube
Download Data - https://goodly.co.in/wp-content/uploads/2022/07/ Create - Dynamic - Columns -Power-Query-Output.xlsx➜ Post Your Answers Here ...
Read more >
how do i can create columns in sql dynamically? - Microsoft Q&A
First of all, whether your metadata only has the PostMonth column, and how to guarantee the value of the new column and row,...
Read more >
Using FixedColumns with dynamically generated columns
Using FixedColumns with dynamically generated columns ... I have an empty table (no headers, no rows, etc.), with everything inside is initialized ...
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