简体   繁体   English

在错误的Ag-Grid单元上显示的角度工具提示

[英]Angular Tooltip showing on the wrong Ag-Grid cell

I am using Ag-grid to generate a table, I have cell validation which checks the value of the cell. 我正在使用Ag-grid生成表,我进行了单元格验证以检查单元格的值。 On wrong value I want to show a tooltip . 对于错误的值,我想显示一个工具提示 I've managed to do all of this, except that the Tooltip doesn't show on the cell with the wrong input but on the first cell to the right and only there. 我已经做到了所有这些,除了工具提示不是在输入错误的单元格上显示,而是在右边的第一个单元格上显示,仅在那儿显示。

在此处输入图片说明

My code 我的密码

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

Well I don't know why exactly, but this solves the issue : 好吧,我不知道为什么,但这解决了这个问题:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM