Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Material-UI DataGrid: How do I add a tooltip to each row cell?

I could not find anything related to this in the react material ui datagrid documentation here. I noticed you can add tooltips to columns via a "description" field, but can not find any documentation or examples related to rows.

like image 584
rgins16 Avatar asked Jan 25 '23 14:01

rgins16


1 Answers

modify columns to add renderCell attribute

const columns: Columns = [
  {
    field: 'id',
    headerName: 'ID',
    sortable: false,
    renderCell: (params: any) =>  (
       <Tooltip title={params.data.id} >
        <span className="table-cell-trucate">{params.data.id}</span>
        </Tooltip>
      ),
  }
]

css changes :

.table-cell-trucate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
like image 51
Nityanand kar Avatar answered May 25 '23 03:05

Nityanand kar