我正在尝试显示ag-grid元素中包含的所有数据。列数各不相同,有些网格很宽,因此某些数据仅在水平滚动时才可见。我需要显示所有这些数据以进行打印,因此隐藏列的数据需要发送到新的网格中进行显示。
<ag-grid-angular
style="width: 100%; height: 700px;"
class="ag-theme-balham"
[rowData]="assetsGridData"
[columnDefs]="columns"
[gridOptions]="gridOptions"
pagination="true"
paginationAutoPageSize="false"
paginationPageSize="100"
[statusBar]="statusBar"
[defaultColDef]="defaultColDef"
(gridReady)="onGridReady($event)"></ag-grid-angular>
这在ngInit()中:
loadDataAndSetValues() {
this.isGridDataLoading = true;
this.service.getCni().subscribe(data => {
this.assetsGridData = data;
setTimeout(() => {
var allColumnIds = [];
this.gridColumnApi.getAllColumns().forEach(function(column) {
allColumnIds.push(column.colId);
});
this.gridColumnApi.autoSizeColumns(allColumnIds);
this.preSelectRows();
this.isExternalFilterActive =
this.gridApi.getSelectedNodes().length > 0;
this.gridApi.onFilterChanged();
this.isGridDataLoading = false;
}, 500);
})
}