【发布时间】:2022-09-30 15:32:14
【问题描述】:
可以说我有一个表,有时很少有数据可以为空,但空数据在表中显示未定义而不是显示未定义我想显示“N/A”我如何才能实现共享图像和下面的代码。
在上图中的参考数据下,一些数据显示未定义,因为它为空,我希望它显示“N/A”。我将在下面分享代码。下面的代码有 \"a.normalRange\" 变量,该变量保存参考数据。
var col = [\"Test Name\", \"Result\", \"Unit\" , \"Reference\"];
this.hubxDataItemSpList.forEach((a) => {
medicineInfo = this.hubxDataItemSpList.find(x => x.id == a.id);
rows.push([\'\' + a.categoryName +\' \'+ a.itemTitle + \'\', \'\' + a.itemValue + \'\', \'\' + a.itemUnit ,\'\' + a.normalRange]);
});
这是我的模特
export class HubxDataItemSpModel {
id: number;
categoryId: number;
categoryName:string;
itemTitle: string;
itemUnit: string;
isActive: boolean=true;
itemValue: string;
patientId: number;
clinicianHubXSign : string;
isAprrovedStatus : boolean;
isTestApproved : boolean;
phySignDate : Date;
notes : string;
normalRange : string;
//base64:any;
isDeleted: boolean;
createdDate : Date
}
这就是我在组件类中定义模型的方式
hubxDataItemSpList : Array<HubxDataItemSpModel>=[];
这就是我打印表格的方式
doc.autoTable({
columnStyles: {
0: { cellWidth: 45 },
1: { cellWidth: 45 },
2: { cellWidth: 45 },
3: { cellWidth: 45 }
},
head: [col],
body: rows,
startY: 100,
theme: \'plain\',
tableLineColor: [242, 238, 238],
tableLineWidth: 0.5,
styles: {
font: \'courier\',
lineColor: [242, 238, 238],
lineWidth: 0.5
},
});
-
你能把你那行的html代码贴出来吗
标签: angular