2

我正在使用主要反应数据表显示数据表,当鼠标悬停在单元格上时,我想显示工具提示或标题,如下图所示。

在此处输入图像描述

我浏览了 Column 组件,但没有找到任何相关的关键字来在单元格上显示工具提示或标题,该单元格用于显示数据表中的列。

代码:

<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>

来源:https ://primefaces.org/primereact/showcase/#/datatable/edit

您的回答将不胜感激!

4

1 回答 1

4

解决此问题的一种方法是为您的列使用自定义正文。像这样:

<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>

按钮上的工具提示

不幸的是,我无法在rowEditor设置属性的同时让它工作,就像你的例子一样。

于 2020-09-30T05:34:23.563 回答