Referred example from Printing section of ag-grid documentation (https://www.ag-grid.com/javascript-grid-for-print/). This is the snippet from typescript file .
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 .