Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use e.stopPropagation() in react bootstraap table column? #1470

Open
kyou-ennbunn opened this issue Sep 7, 2020 · 1 comment
Open

Comments

@kyou-ennbunn
Copy link

👍

Originally posted by @AllenFang in #1042 (comment)

@congweibai
Copy link

I figured out the case for myself:

After e.stopPropagation() for un-used columns, bind customised action for column

  const [showConfirmModal, setShowConfirmModal] = useState(false);
  // store targeted Id for API purpose
  const activeId = useRef(null);
  // UI purpose for calculate modal postion
  const [activeIndex, setActiveIndex] = useState(0);

  const rowEvents = {
    onClick: (e, row, rowIndex) => {
      setActiveIndex(rowIndex);
      setShowConfirmModal(true);
      activeId.current = row.id;
    },
  };

UI

  {showConfirmModal ? (
    <div
      className="delete-confirm-modal"
      style={{
        position: 'absolute',
        // based on rowIndex and rowHeight: 50px
        top: `${(activeIndex + 1) * 50}px`,
        right: '-90px',
      }}
    >
      Confirm delete?
      <div>
        <button
          onClick={() => {
            setShowConfirmModal(false);
          }}
        >
          Cancel
        </button>
        <button
          onClick={() => {
            // use for API
            console.log('activeId', activeId.current);
          }}
        >
          Confirm
        </button>
      </div>
    </div>
  ) : null}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants