Search code examples
datagridmaterial-ui

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.


Solution

  • 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;
    }