Venu
Venu

Reputation: 348

PrimeReact Data table - How to show tooltip or title on a cell?

I'm display a data table using prime react data table and I wanted to show tooltip or title like marked in below image, when mouse over doing on a cell.

enter image description here

I went through the Column component and i didn't find any relevant keyword to display tooltip or title on a cell, which is being used to show columns in data table.

Code:

<DataTable
  value={this.state.products3}
  editMode="row"
  dataKey="id"
  onRowEditInit={this.onRowEditInit}
  onRowEditCancel={this.onRowEditCancel}
>
  <Column field="code" header="Code" editor={(props) => this.codeEditor('products3', props)}></Column>
  <Column rowEditor headerStyle={{ width: '7rem' }} bodyStyle={{ textAlign: 'center' }} title='Edit'></Column>
</DataTable>

Source: https://primefaces.org/primereact/showcase/#/datatable/edit

Your answer will be appreciated!

Upvotes: 3

Views: 4694

Answers (2)

marouan azizi
marouan azizi

Reputation: 417

<Tooltip
  target=".p-dt-tooltip"
  content="Edit"
  mouseTrack
  mouseTrackLeft={10}
/>
<DataTable
  value={this.state.products3}
  editMode="row"
  dataKey="id"
  onRowEditInit={this.onRowEditInit}
  onRowEditCancel={this.onRowEditCancel}
>
  <Column field="code" header="Code" editor={(props) => this.codeEditor('products3', props)}></Column>
  <Column className="p-dt-tooltip" rowEditor headerStyle={{ width: '7rem' }} bodyStyle={{ textAlign: 'center' }} title='Edit'></Column>
</DataTable>

Upvotes: 0

zeepk
zeepk

Reputation: 150

One way to fix this would be to use a custom body for your column. Like this:

<Column body={() => <Button icon="pi pi-pencil" className="p-button-rounded p-button-text" tooltip="Here's the tooltip!" />} headerStyle={{ width: '7rem' }} bodyStyle={{ textAlign: 'center' }} title="Edit"></Column>

tooltip on button

Unfortunately I could not get this to work while also having the rowEditor property set, as in your example.

Upvotes: 5

Related Questions