Friday, June 22, 2012

Printing a table with Print.it.

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;
}
}

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment