0

Hello I have a table with some columns, data is taken from an API. Now I need to add another column where I will add a button with my own functionality (different functionality for each row). Can I somehow do it?

    <BootstrapTable
      data={content}
      version="4"
      striped
      hover
      remote
      fetchInfo={{ dataTotalSize: totalSize }}
      pagination
      options={{
        onPageChange: this.onPageChange,
        hideSizePerPage: true,
        page: filters.page + 1,
        sizePerPage: filters.size,
        onFilterChange: this.onFilterChange,
      }}
      keyField="id"
      trClassName="tableRow"
      containerClass={content.length > 0 ? 'fullTable' : undefined}
    >
      {tableHeaders.map(header => (
        <TableHeaderColumn
          filter={header.filter}
          key={header.id}
          dataField={header.id}
          thStyle={{
            whiteSpace: 'normal',
            textAlign: 'center',
            lineHeight: 2,
          }}
          dataFormat={header.date && this.dateFormatter}
          width={header.width}
        >
            {header.name}
        </TableHeaderColumn>
      ))}
    </BootstrapTable>

I am using "react-bootstrap-table": "4.3.1".

ProgrammerPer
  • 1,125
  • 1
  • 11
  • 26
jake-ferguson
  • 315
  • 3
  • 11
  • 32
  • You are using the [old bootstrap table](https://github.com/AllenFang/react-bootstrap-table) new one does not use `TableHeaderColumn`. Documentation of the new table can be found [here](https://react-bootstrap-table.github.io/react-bootstrap-table2/storybook/index.html?selectedKind=Welcome&selectedStory=react%20bootstrap%20table%202%20&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybook%2Factions%2Factions-panel). – HMR Sep 12 '18 at 06:51
  • Maybe [custom row selection](https://react-bootstrap-table.github.io/react-bootstrap-table2/storybook/index.html?selectedKind=Row%20Selection&selectedStory=Custom%20Selection&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybook%2Factions%2Factions-panel) can work for you. Or [dummy column](https://react-bootstrap-table.github.io/react-bootstrap-table2/storybook/index.html?selectedKind=Work%20on%20Columns&selectedStory=Dummy%20Column&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybook%2Factions%2Factions-panel) – HMR Sep 12 '18 at 06:53
  • HMR yes i know, in my project I must use the old ver. – jake-ferguson Sep 12 '18 at 06:59
  • unfortunately custom row selection can't do it... – jake-ferguson Sep 12 '18 at 07:23
  • Did you try `tableHeaders` to have one more item that has a formatter returning a react component? You could pass the current data item as props to this component and give it an onClick. – HMR Sep 12 '18 at 07:25
  • well its sounds like it could work, BUT there is nothing in API so i cannot pass any onClick or sth like this.... – jake-ferguson Sep 12 '18 at 07:50
  • You can try: `[{dataFormat:()=>()}]` – HMR Sep 13 '18 at 06:43

0 Answers0