constantin-p / cp-react-tree-table

A fast, efficient tree table component for ReactJS.
https://constantin.software/cp-react-tree-table
MIT License
94 stars 27 forks source link

Is this project active? Last post in Nov last year #42

Closed progenysw closed 2 years ago

progenysw commented 2 years ago

I can't find anything in the doc to trap[ and onclick for a specific row"

constantin-p commented 2 years ago

The library defers the job of rendering cells to the consumer code - you can attach an onClick listener to the wrapper node returned by your custom cell rendering function to achieve this.

E.g.:

<TreeTable
  value={treeValue}
  onChange={handleOnChange}>

  <TreeTable.Column
    renderCell={(row) => <span onClick={(e) => { console.log("Click on row:", row, e); }}>{row.data.name}</span>}
    //  ^ used to render all cells corresponding to the "Name" column
    renderHeaderCell={() => <span>Name</span>}/>
  <TreeTable.Column
    renderCell={(row) => <span onClick={(e) => { console.log("Click on row:", row, e); }}>{row.data.employees}</span>}
    //  ^ used to render all cells corresponding to the "Employees" column
    renderHeaderCell={() => <span>Employees</span>}/>
  ...
</TreeTable>