Hello when the grid prints there is no styles attached to the print. Is the only way to attach styles to loop through every cell of the table. Is there no way to just attach a stylesheet.
Hi Charles Eichelberger,
Greetings from syncfusion support.
Query:” Print not using any styles”
Before providing the solution, we need some more clarification. This will help us to validate further and provide the solution as soon as possible.
Regards,
Nithya Sivaprakasam.
Hello
We would like the print view and live view of our tables to match styles. We would like to do this without having to loop through every cell to attach styling possibly by attaching a stylesheet for the print view to use. Below are examples of the live view and print views of our table. We are using version 20.1.52.
Live View
Print View
Hi Charles,
Currently, we are validating your query and we will update further details on June 3rd,2022. Until then, appreciate your patience.
Regards,
Nithya Sivaprakasam.
Hi Charles,
Still we are validating your query and we will update further details on June 6,2022. Until then, appreciate your patience.
Regards,
Nithya Sivaprakasam.
Hi Charles,
Sorry for the inconvenience caused.
Query: Print not using any styles
Based on this query, we would like to inform you that we do not feasible to print the grid with styles options however we suggest you export the file in PDF format with styling then you can print the grid in your custom CSS style. In the PdfQueryCellInfo event, you can customize any style in the grid. PdfQueryCellInfo triggers before exporting each cell to a PDF document. So you can apply the grid cells.
Please check the below code for reference.
Code Snippet:
|
[app.component.ts] import { Component, OnInit, ViewChild, ValueProvider, ViewEncapsulation, } from '@angular/core'; import { employeeDetails } from './data'; import { GridComponent, ToolbarService, PdfExportService, } from '@syncfusion/ej2-angular-grids'; import { ClickEventArgs } from '@syncfusion/ej2-navigations';
@Component({ selector: 'app-root', templateUrl: 'app.component.html', styleUrls: ['app.component.css'], encapsulation: ViewEncapsulation.None, providers: [ToolbarService, PdfExportService], }) export class AppComponent { public data: Object[]; public toolbar: string[]; public pageSettings: Object; public isInitial: Boolean = true; @ViewChild('grid') public grid: GridComponent;
public ngOnInit(): void { this.data = employeeDetails; this.toolbar = ['PdfExport']; this.pageSettings = { pageCount: 5 }; }
toolbarClick(args: ClickEventArgs): void { switch (args.item.text) { case 'PDF Export': this.grid.pdfExport(); break; } }
QueryCellInfo = (args: any) => { args.cell.bgColor = '#ffffb3'; };
PdfQueryCellInfo = (args: any) => { console.log(args); args.style = { backgroundColor: '#ffffb3' }; // you can style the grid here }; }
[app.component.html]
<div class="col-lg-9 control-section"> <ejs-grid #grid [dataSource]="data" [toolbar]="toolbar" (toolbarClick)="toolbarClick($event)" [allowPdfExport]="true" (pdfQueryCellInfo) = "PdfQueryCellInfo($event)" (queryCellInfo)="QueryCellInfo($event)" > <e-columns> <e-column field="FirstName" headerText="Name" width="130"></e-column> <e-column field="Title" headerText="Designation" width="180"></e-column>
<e-column field="HireDate" headerText="Hire Date" width="135" textAlign="Right" format="yMd" ></e-column> <e-column field="Address" width="180" [allowGrouping]="false"></e-column> </e-columns> </ejs-grid> </div> |
We attached a sample for reference.
Sample: https://stackblitz.com/edit/angular-huthck-lq6mpk?file=app.component.html,app.component.ts
Documentation: https://ej2.syncfusion.com/angular/documentation/api/grid/#pdfquerycellinfo
Please get back to us if you need further assistance.
Regards,
Nithya Sivaprakasam.
Hi I was not talking about the pdf exporting but the regular printing
Hi Charles,
Currently, we are validating your query "Print the grid with styles" and we will update further details on or before June 10th, 2022.
We appreciate your patience until then.
Regards,
Nithya Sivaprakasam.
Hi Charles,
Thanks for your patience.
Query:” Print not using any styles in the grid”
We would like to inform you that we do not have the support to print the grid with style. However, we suggest you export the file in PDF format with styling then you can print the grid with your custom CSS. In the PdfQueryCellInfo event, you can customize any style in the grid. PdfQueryCellInfo triggers before exporting each cell to a PDF document. So you can apply the style in grid cells.
Regards,
Nithya Sivaprakasam.
Hello,
Is there changes now in 2025 for the original inquery about styles directly to print without exporting to pdf first?
Thanks
Dani
Hello,
Is there changes now in 2025 for the original inquery about styles directly to print without exporting to pdf first?
Thanks
Dani
Hi Daniel,
Sorry for the inconvenience.
Based on your query, it seems that the custom styles you applied to the grid are not being reflected in the print preview. This issue often occurs because browsers do not automatically include background styles or custom styling during printing.
To resolve this, we recommend enabling the Background Graphics option from the print preview.
By enabling this option, the grid styles should appear correctly in the print output.
Please get back to us for further assistance.
Regards,
Dineshnarasimman M