Gray border/lines appear around Data Grid 2 when generating PDF using page

0
Hi everyone,I’m facing an issue when generating a PDF from a Mendix page.Currently, I’m using Data Grid 2 to display information on the page, and this page is used as the source for PDF generation. However, when the PDF is generated, the Data Grid 2 appears with gray lines/borders around the grid and cells, even though I did not intentionally add any borders or custom styling.I’ve checked the following:No custom CSS added specifically to this Data Grid 2Default styling is being usedThe issue only appears in the generated PDF, not in normal page view (or appears differently)Questions:Is this gray line/border a default style applied by Data Grid 2 when rendering PDFs?Is there a recommended way to remove or override these borders specifically for PDF generation?Should this be handled via custom CSS, PDF-specific styling, or by using another widget (e.g. legacy Data Grid or List View)?Any guidance or best practices would be greatly appreciated.Thank you in advance.
asked
2 answers
0

First, create a separate page specifically for PDF generation. This page will only be used to generate the PDF and won’t be opened directly by users. You can name it something like MyEntity_PDF.


On this page, wrap everything inside an outer container and give it a class name, for example pdf-export. Any PDF-specific CSS will be written under this class.


Place the content you want to show in the PDF on this page. You can use the same data as the UI page, but in most cases a simpler layout (fewer widgets, less nesting) works much better for PDFs.


Then, in the microflow that generates the PDF, select this PDF page as the “page to render” instead of the normal UI page. If needed, pass the same context object as a page parameter.


On the CSS side, add overrides that target only the PDF, using the pdf-export class. Since this class exists only on the PDF page, the normal UI will not be affected.


answered
0

This behavior is expected in Mendix: Data Grid 2 applies print/PDF default styles that add gray borders during PDF rendering, even if no borders are visible on the page. Data Grid 2 is not recommended for PDF generation. The best practice is to generate PDFs using a Document Template with tables or List Views for full styling control; alternatively, you can remove the borders using PDF-specific (@media print) CSS, but this approach is less reliable.

or


Override PDF-specific CSS

If you must keep using Data Grid 2:

Add custom CSS that only applies during print/PDF rendering.


Example:


@media print {
  .mx-datagrid,
  .mx-datagrid table,
  .mx-datagrid th,
  .mx-datagrid td {
    border: none !important;
  }
}


answered