Search code examples
javascriptreactjsreact-bootstrap-table

How to pass the content of your columns to a dummyField in react-bootstrap-table2


I'm trying to pass the value of my columns datafield to my buttons in react-bootstrap-table2 dummyField. And I don't quite know how to do it. this is my columns datafield.

const columns = [
    {
      dataField: "firstName",
      text: "First Name",
    },
    {
      dataField: "middleName",
      text: "Middle Name",
    },
    {
      dataField: "lastName",
      text: "Last Name",
    },
    {
      dataField: "sex",
      text: "Sex",
      sort: true,
    },
    {
      dataField: "rootChapter",
      text: "Root Chapter",
    },
    {
      dataField: "municipalCouncil.name",
      text: "Council",
      sort: true,
    },
    {
      dataField: "batchName",
      text: "Batch Name",
      sort: true,
    },
    {
      dataField: "alias",
      text: "Alias",
    },
    {
      dataField: "actions",
      text: "Actions",
      isDummyField: true,
      formatter: (cell, row) => <MemberButtons member={columns} id={row._id} />, // Overhere is the problem
    },
  ];

I'm doing this because of the modal. I'm a beginner to React.js and specially to react-bootstrap-table2.


Solution

  • So it works by doing this

    {
          dataField: "actions",
          text: "Actions",
          isDummyField: true,
          formatter: (cell, row) => <MemberButtons values={row} id={row._id} />, // By passing row variable to values I got all the contents of my datafields
        },
    

    Thank you for those who tried to help me.. If you found a better way to do this please dont hesitate to post it here.. Thanks :)