ag-grid文档(https://www.ag-grid.com/javascript-grid-for-print/)的“打印”部分中的引用示例。 这是打字稿文件的片段。
onBtPrint(){
var gridApi = this.gridApi;
this.setPrinterFriendly(gridApi);
setTimeout(function() {
print();
this.setNormal(gridApi);
}, 2000);
}
setPrinterFriendly(gridApi) {
var eGridDiv = document.querySelector(".my-grid");
(eGridDiv as HTMLElement).style.width = "";
(eGridDiv as HTMLElement).style.height = "";
this.gridApi.setDomLayout("print");
}
setNormal(gridApi) {
var eGridDiv = document.querySelector(".my-grid");
(eGridDiv as HTMLElement).style.width = "600px";
(eGridDiv as HTMLElement).style.height = "200px";
this.gridApi.setDomLayout("print");
}
Below is my html template , on clicking print button i am trying
to call onBtPrint()
<button (click)="onBtPrint()">print</button>
<div class="bx--row" [ngStyle]="style">
<div class="bx--col-md-12" >
<ag-grid-angular #agGrid style="width: 100%; height: 600px;" class="ag-theme-balham my-grid" id="myGrid"
[gridOptions]="gridOptions"
[columnDefs]="columnDefs"
[rowData]="rowData"
[defaultColDef]="defaultColDef"
[domLayout]="domLayout"
(gridReady)="onReady($event)"
</ag-grid-angular>
<div>
<input style= "opacity:0" readonly #modal>
</div>
</div>
Which version of ag-grid should i use .
答案 0 :(得分:0)
您使用的ag-grid 18.1 api没有引入setDomlayout属性。因此,您只需要为此功能将ag-Grid更新到v20。