PrimeReact数据表-如何在单元格上显示工具提示或标题?

问题描述

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

enter image description here

我遍历了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

您的回答将不胜感激!

解决方法

解决此问题的一种方法是对列使用自定义主体。像这样:

<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

不幸的是,就像您的示例一样,我在设置rowEditor属性的同时也无法正常工作。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...