console.log("select")} while" /> console.log("select")} while" /> console.log("select")} while"/>

PrimeReact Datatable cannot use onCellClick while having a checkbox column

211 views Asked by At

Hello I have an issue with PrimeReact were I cannot use onCellClick={() => console.log("clicked")} OR onCellSelect={() => console.log("select")} while having a checkbox column

<Column
          selectionMode="multiple"
          headerStyle={{ width: "3rem" }}
        ></Column>

I wanted to know if it is a known issue and if there is a workaround.

Here is a demo on codesandbox: https://codesandbox.io/s/primereact-demo-forked-6vyf5l?file=/src/App.js

Regards

I tried creating my own checkbox column. however I cant update the state of the checkbox. Since I can't pass a function/state updater.

<Column
          selectionMode="multiple"
          onClick= ...
          headerStyle={{ width: "3rem" }}
        ></Column>
1

There are 1 answers

0
Melloware On

See my sandbox: https://codesandbox.io/s/primereact-demo-forked-9jjmhw?file=/src/App.js

CellSelection is NOT allowed in checkbox mode or radio mode but only on single select mode. It is due to this code in PrimeReact.

const allowCellSelection = () => {
    return props.cellSelection && !isRadioSelectionModeInColumn && !isCheckboxSelectionModeInColumn;
};