JSX rendering dynamic TableHeaderColumn
See original GitHub issueI am trying to dynamically generate the TableHeaderColumn within the BootstrapTable component, although cannot do it and receive an error.
The following works:
<BootstrapTable
data={products2} striped={true} hover={true} condensed={true} columnFilter={true} pagination={true} search={true}>
<TableHeaderColumn dataField="id" isKey={true} dataAlign="left" width="70px" dataSort={true}>#</TableHeaderColumn>
<TableHeaderColumn dataField="carfilename" dataSort={true} width="300px">Car filename</TableHeaderColumn>
<TableHeaderColumn dataField="local" dataSort={true} width="300px">local</TableHeaderColumn>
<TableHeaderColumn dataField="localDev" dataSort={true} width="300px">localDEV</TableHeaderColumn>
<TableHeaderColumn dataField="DEV" dataSort={true} width="300px">DEV</TableHeaderColumn>
<TableHeaderColumn dataField="TRN" dataSort={true} width="300px">TRN</TableHeaderColumn>
</BootstrapTable>
However I need to generate the environment columns dynamically, but the following does not work:
<BootstrapTable data={products2} striped={true} hover={true} condensed={true} columnFilter={true} pagination={true} search={true}>
<TableHeaderColumn dataField="id" isKey={true} dataAlign="left" width="70px" dataSort={true}>#</TableHeaderColumn><TableHeaderColumn dataField="carfilename" dataSort={true} width="300px">Car filename</TableHeaderColumn>
{envColumns}
</BootstrapTable>
Related code:
envColumns.push(<EnvironmentHeaderColumn envname={envvalue.envName} key={envkey} />);
var EnvironmentHeaderColumn = React.createClass({
render: function () {
var env = this.props.envname;
// console.log('env is ' + env);
return (
<TableHeaderColumn dataField={env} dataAlign="center">{env}</TableHeaderColumn>
);
}
});
I receive the following error in Google Chrome:
Uncaught TypeError: Cannot read property ‘children’ of undefined
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Dynamically generated columns · Issue #450 - GitHub
Do you know of a way to dynamically generate columns? I have something like this in mind (inside the render method): const columns...
Read more >Problems passing a dynamic link to the table - Stack Overflow
I'm using react-bootstrap-table here, but every other option is a good deal. I have a big problem inserting a Link to the table....
Read more >React Bootstrap Table - Contributors - GitHub Pages
List all contributors for react-bootstrap-table. ... <BootstrapTable data={data} > <TableHeaderColumn dataField="name" ... Dynamic Select Row.
Read more >[Solved]-How to do React-Table Dynamic Header?-Reactjs
How to customize React Antd table header with table data? ... How to get dynamic table header from an array in react? ......
Read more >How To Create Dynamic Table In React JS #reactjs ... - YouTube
Consultation: learningcurvebook@gmail.comText only #: 740-764-6334 # react #reactjs #tutorial #coding #webdev #webdevelopment #programming In ...
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
thanks very much for your help Allen. I managed to resolve some issues with column alignment (i.e. by fixing the # width) as well as use the advanced column filter. I also used the column formatter and applied some conditional styling to it. All good so far 😃
@tester5, sorry for lately reply,
Cause you leave one column in the BootstrapTable child, like your snippet,
you can fix it by following:
Thanks 😃