在 Angular6 的 AG 网格中下载导出到 csv 功能中的不可见字段
Download invisible fields in export to csv functionality in AG grid in Angular6
我有一个 pojo 数组,我将它用于我的 ag-grid 的 rowData
export interface Items {
firstName?: String;
lastname?: String;
Address?: String;
phoneNumber?: number;
city?: String;
state?: String;
zipcode?: number;
accountId?: number;
status?: String;
approvalStatus?: String;
txId?: number;
rxId?: number;
txBankname?: String;
rxBankName?: String;
txCcy?: String;
rxCcy?: String;
txCcyAmt?:number;
rxCcyAmt?:number;
txDate?:date;
rxDate?:date;
}
但是我没有在网格中显示所有数据。但是我想下载网格中未显示但在 rowData 或 POJO 中可用的其他数据。
<button mat-icon-button (click)="agGrid.api.exportDataAsCsv()" matTooltip="CSV Download">
<i class="fa fa-download" style="color:#455A64" aria-hidden="true"></i>
</button>
此点击只会下载 link 中给出的网格中可见的数据
here
但是如果我们想将 POJO 的其他属性下载到 csv 中,我们该怎么做。
You have two options, let the grid do the export if the browser is modern and it is allowed, or you get the grid to return you the CSV string and your application is responsible for the export
如果您选择让网格进行导出,则可以使用一个附加选项 allColumns
。 如果 allColumns=true
那么所有隐藏和可见的列都将被导出
但是,听起来您不仅要导出隐藏的列数据,还要将数据添加到未包含在网格中的 CSV 中。如果是这种情况,您将需要选择在您的应用程序中为您提供网格 return CSV 字符串,并使用自定义方法在完成导出之前将您想要的数据添加到 CSV。
我有一个 pojo 数组,我将它用于我的 ag-grid 的 rowData
export interface Items {
firstName?: String;
lastname?: String;
Address?: String;
phoneNumber?: number;
city?: String;
state?: String;
zipcode?: number;
accountId?: number;
status?: String;
approvalStatus?: String;
txId?: number;
rxId?: number;
txBankname?: String;
rxBankName?: String;
txCcy?: String;
rxCcy?: String;
txCcyAmt?:number;
rxCcyAmt?:number;
txDate?:date;
rxDate?:date;
}
但是我没有在网格中显示所有数据。但是我想下载网格中未显示但在 rowData 或 POJO 中可用的其他数据。
<button mat-icon-button (click)="agGrid.api.exportDataAsCsv()" matTooltip="CSV Download">
<i class="fa fa-download" style="color:#455A64" aria-hidden="true"></i>
</button>
此点击只会下载 link 中给出的网格中可见的数据 here
但是如果我们想将 POJO 的其他属性下载到 csv 中,我们该怎么做。
You have two options, let the grid do the export if the browser is modern and it is allowed, or you get the grid to return you the CSV string and your application is responsible for the export
如果您选择让网格进行导出,则可以使用一个附加选项 allColumns
。 如果 allColumns=true
那么所有隐藏和可见的列都将被导出
但是,听起来您不仅要导出隐藏的列数据,还要将数据添加到未包含在网格中的 CSV 中。如果是这种情况,您将需要选择在您的应用程序中为您提供网格 return CSV 字符串,并使用自定义方法在完成导出之前将您想要的数据添加到 CSV。