Angular 工具提示显示在错误的 Ag-Grid 单元格上

Angular Tooltip showing on the wrong Ag-Grid cell

我正在使用 Ag-grid 生成一个 table,我有单元格验证来检查单元格的值。在错误的值上,我想显示一个 工具提示 。我已经设法完成了所有这些,除了 工具提示不会显示在输入错误的单元格上,而是显示在右边的第一个单元格上,而且只显示在那里。

我的代码

data.map(object => {
        Object
          .keys(object)
          .map(key => {
            let mappedColumn = {
              headerName: key,
              field: key,
              hide: this.configurationSettings.hide,
              cellRenderer: "cellEditorComponent",    
              pinned: null,             
              inputType: this.inputType,
              cellStyle: (event) => { return this.cellValidation(event) },
              tooltip: (event) => { return this.setErrorMessage(event) }
            }
        columnDefinitions.push(mappedColumn);

cellValidation(param: any) {
    this.isValid=true;
    if (param && param.node && !param.node.lastChild && this.validateInput && !this.validateInput.test(param.value))
    {
      this.isValid = false;
      return { 'background-color': 'rgb(255, 230, 230)', 'border-color': 'red', 'font-weight': 'normal'    }
        }else if (param && param.node && param.node.lastChild && param.node.data["Consultant"] == "Planned hours")
        {
          return {'font-weight': 'bold'};
        }
}

     setErrorMessage(param: any) {
        //if (param && this.cellValidation(param) != null)
        if (!this.isValid) { 
          return this.errorMessage; 
        }
      }

嗯,我不知道为什么,但这解决了问题:

 setErrorMessage(param: any) {
    if (param && this.cellValidation(param) != null && !this.isValid)
    { return this.errorMessage;}}