Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Virtualized Table only showing one column

I'm using react-virtualized's table and defined 4 columns for that table. For some reason it only displays the 1st column. I can not get the other columns to display. Not sure what I'm doing wrong. Below is a snippet of the code:

const BTable = ({bdata}) => { 
return(
    <AutoSizer disableHeight>
        {({ width }) => (
            <Table
                headerHeight={20}
                height={300}
                width={width}
                overscanRowCount={5}
                rowHeight={20}
                rowGetter={({index}) => (bdata[index])}
                rowCount={bdata.length}
                noRowsRenderer={() => (<div></div>)}>
                <Column
                    label='Id'
                    cellDataGetter={
                      ({ columnData, dataKey, rowData }) => (rowData[dataKey])
                    }
                    dataKey='id'
                    width={200}
                    />      
                <Column
                    label='Account'
                    cellDataGetter={
                      ({ columnData, dataKey, rowData }) => (rowData[dataKey])
                    }
                    dataKey='account'
                    width={200}
                    />      
                 ....
                 ....
         </Table>
     <AutoSizer>
)
like image 409
Los Morales Avatar asked Oct 27 '25 03:10

Los Morales


2 Answers

I just ran into this problem, turns out I forgot to import the CSS file from react-virtualized. import 'react-virtualized/styles.css' in index.js (or wherever you'd like to import it).

like image 198
Adam Avatar answered Oct 28 '25 15:10

Adam


For anyone else struggling with it.

I've resolved the problem by not using css modules in my webpack config. So make sure the css file got included properly and you've excluded the css modules from whatever the bundler you're using.

like image 26
poplaw Avatar answered Oct 28 '25 17:10

poplaw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!