0

I am using GWT/GXT.

i have used GWT's grid and each row is highighted in background color using CSS. but applied css is not printed in printed page. how can i print with css?

I am calling Print functionality as below:

Print.it("<link rel='StyleSheet' type='text/css' media='paper' href='mainApplication.css'>", DOM.getElementById("myId"));

in mainApplication.css i placed style as below:

@media print {
    print_background {
    background-color: #EBECE4 !important;
    }
  }

is my CSS style correct? Please help me.

in the code :

i created a horizontal panel and added GWT grid to it as below.

HorizontalPanel recordsPanel = new HorizontalPanel();

//GWT grid is created and the same is added to recordsPanel 
recordsPanel .add(grid).

i applied css style for grid rows as below:

recordsGrid.getRowFormatter().addStyleName(i, "print_results_background");

Now i want to print the records with css style.

Thanks!

4

3 回答 3

1

您的 CSS 样式对于一个小问题是不正确的:在 print_background 类之前缺少点 (.)。正确的代码是:

@media print {
     .print_background {
           background-color: #EBECE4 !important;
     }
}
于 2012-09-17T10:08:12.413 回答
1

papermedia不是该属性的有效值。更正您的link标签,如下所示:

<link rel='stylesheet' type='text/css' media='print' href='mainApplication.css' />

忽略其他张贴者提到的其他语法错误,请参阅 RAS 对该问题的评论(关于不同的类名)。

参考

于 2012-09-19T10:28:09.697 回答
0

我认为您在 css 中缺少指定 print_background 是 id # 还是 class 。

于 2012-09-17T10:08:22.430 回答