0

我正在使用开发极端数据网格,如果日期不可用,我会显示为空白。如果日期为空,我想显示“-”。

我试过了

// component.html
[customizeText]="customizeMyText"

// component.ts
 customizeMyText(cellInfo: any) {
    console.log(cellInfo);
    if (cellInfo.value == '' || cellInfo.value == null || cellInfo.value == undefined) {
      return 'NA';
    } else {
      return cellInfo.value;
    }
 }

但它给出了一个错误, text.replace 不是一个函数。

4

1 回答 1

0

customizeText 函数的返回值需要一个字符串,请将您的函数更改为使用 valueText:

customizeMyText(cellInfo) {
if (
  cellInfo.value === "" ||
  cellInfo.value === null ||
  cellInfo.value === undefined
) {
  return "NA";
} else {
  return cellInfo.valueText;
}

};

来源:https ://js.devexpress.com/Documentation/ApiReference/UI_Widgets/dxDataGrid/Configuration/columns/#customizeText

于 2020-06-12T01:21:21.350 回答