2

I am trying to implement a table using 'react-bootstrap-table-next'. I want the row to be editable only after the click of the 'edit' button. Currently, with my code on click of the cell, the cell is changed into an editable cell.

Screenshot of what I want to achieve.

enter image description here

My Code:

import BootstrapTable from 'react-bootstrap-table-next'
import cellEditFactory from 'react-bootstrap-table2-editor';

 const buttonFormatter = (cell, row) => {
    console.log(cell,row)
    return <Button onClick={()=>{editTenantHandler(cell,row)}}><FaEdit/></Button>;
}

  const columns = [{
    dataField: 'tenantName',
    text: 'Tenant Name',
    headerStyle: {
      color: 'white'
    }
  }, {
    dataField: 'email',
    text: 'Email',
    headerStyle: {
      color: 'white'
    }
  }, {
      dataField: 'mobile',
      text: 'Mobile',
      headerStyle: {
        color: 'white'
      }
    },
    {
      dataField: 'actions',
      text: 'Actions',
      isDummyField: true,
      csvExport: false,
      formatter: buttonFormatter,
      headerStyle: {
        color: 'white'
      }
    }];

  <BootstrapTable 
     keyField='tenantName' 
     data={ props.tenants } 
     columns={ columns } 
     cellEdit={ cellEditFactory({mode: 'click'}) }/>

Avi
  • 102
  • 1
  • 9
  • Have you found a solution? Same use-case here but the feature is not yet implemented in the plugin: https://github.com/react-bootstrap-table/react-bootstrap-table2/issues/1194 – stellasia Apr 03 '21 at 16:34

0 Answers0