Printing a table with Print.it.

140 views
Skip to first unread message

marwijn

unread,
Jun 22, 2012, 3:38:08 AM6/22/12
to Google Web Toolkit
Hello Everyone,

I'm trying to print a cellTable which is not shown on the screen.
However the table is not shown in the print.
The code below is a simplied version that reproduces the problem.
If I try to print the visible cellTable everything works fine.
Printing a new table directly after constructing does not work.
Any suggestions would be welcome.

Thanks in advance.

Marwijn.



package printsprike.client;

import java.util.Arrays;
import java.util.List;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class PrintSpike implements EntryPoint {

List<String> items = Arrays.asList("a", "b", "c");

public void onModuleLoad() {
final CellTable<String> cellTable = createTable();
RootPanel.get().add(cellTable);

final Button printButton = new Button("Print");
printButton.addClickHandler(new ClickHandler(){

@Override
public void onClick(ClickEvent event) {
Print.it(createTable());
}});

RootPanel.get().add(printButton);
}

private CellTable<String> createTable() {
final CellTable<String> cellTable = new CellTable<String>();
final TextColumn<String> column = new TextColumn<String>(){
@Override
public String getValue(String object) {
return object;
}
};
cellTable.addColumn(column, "columnName");
cellTable.setRowData(items);
return cellTable;
}
}

Freller

unread,
Jul 4, 2012, 10:59:05 AM7/4/12
to google-we...@googlegroups.com

Hi Marwijn,

Print.it will only print something that was rendered. If you don't wan't to see it, you
can use a hidden div to render the object and them send it to Print.it.

Regards,
Freller
Reply all
Reply to author
Forward
0 new messages