react-bootstrap-table / react-bootstrap-table2

Next Generation of react-bootstrap-table
https://react-bootstrap-table.github.io/react-bootstrap-table2/
MIT License
1.27k stars 431 forks source link

How to Put Show/Hide Columns in Modal #1458

Open jspin77 opened 4 years ago

jspin77 commented 4 years ago

I have too many columns to show the toggle above the table. I wanted to put them in a modal window instead. The modal appears and the show/hide columns works while the modal is open. As soon as I close the modal, the columns reappear. Here are some snippets from the file:

const CustomToggleList = ({ columns, onColumnToggle, toggles }) => (
  <Modal show={this.state.columnModal} onHide={this.hideColumnModal}>
    <Modal.Header closeButton>
      <Modal.Title>Show/Hide Columns</Modal.Title>
    </Modal.Header>
    <Modal.Body>
      <h4>Text in a modal</h4>
      <div className="" data-toggle="buttons">
        {columns
          .map((column) => ({
            ...column,
            toggle: toggles[column.dataField],
          }))
          .map((column) => (
            <button
              type="button"
              key={column.dataField}
              className={`btn btn-info ${column.toggle ? "active" : ""}`}
              data-toggle="button"
              aria-pressed={column.toggle ? "true" : "false"}
              onClick={() => onColumnToggle(column.dataField)}
            >
              {column.text}
            </button>
          ))}
      </div>
    </Modal.Body>
    <Modal.Footer>
      <Button onClick={this.hideColumnModal}>Close</Button>
    </Modal.Footer>
  </Modal>
);

.... the render method .... return (

{(props) => (
Export
)}
joshuahlee commented 4 years ago

I also have this question. Please advise!

Xuan-Law commented 3 years ago

I also have same problem. Please advise!

shaunlabang commented 3 years ago

same issue here. any solution?

shaunlabang commented 3 years ago

@AllenFang :(