datagrid - 如果开发极端数据网格中的日期为空,则显示“-”
问题描述
我正在使用开发极端数据网格,如果日期不可用,我会显示为空白。如果日期为空,我想显示“-”。
我试过了
// 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 不是一个函数。
解决方案
customizeText 函数的返回值需要一个字符串,请将您的函数更改为使用 valueText:
customizeMyText(cellInfo) {
if (
cellInfo.value === "" ||
cellInfo.value === null ||
cellInfo.value === undefined
) {
return "NA";
} else {
return cellInfo.valueText;
}
};
推荐阅读
- laravel - Laravel 项目在共享主机上使用 bitbucket 管道
- docker - 在 Kubernetes pod 中使用 docker socket
- python - 错误:“make: * [Makefile:163: all] 错误 2”和“make: * [Makefile:163: all] 中断”
- snowflake-cloud-data-platform - 单一模式上的雪花授予选择
- javascript - Angular JS将多个数组传递给scope.list
- javascript - 如何从普通的 Javascript 函数中调用 ReactJS 类组件和功能组件?
- php - 这是否可以在单列中使用两个 id 以在 laravel 中建立模型关系
- javascript - 使用循环将给定数组转换为对象数组
- c# - 使用单个命令生成代码覆盖率报告和单元测试结果(如果可能)
- firebase - 将图像存储为 url 并将其发布到我的应用程序中?