Hello,
I have a problem with the print preview API when the form to print is within a Window object. When i click on the Print Preview button nothing happens.
here you find the test code :
Thank you !
I have a problem with the print preview API when the form to print is within a Window object. When i click on the Print Preview button nothing happens.
here you find the test code :
Code:
package com.is.test.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.fields.DataSourceBooleanField; import com.smartgwt.client.data.fields.DataSourceDateField; import com.smartgwt.client.data.fields.DataSourceFloatField; import com.smartgwt.client.data.fields.DataSourceIntegerField; import com.smartgwt.client.data.fields.DataSourceLinkField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.DynamicForm; /** * Entry point classes define <code>onModuleLoad()</code>. */ public class TestPrintPreviewWindow implements EntryPoint { public void onModuleLoad() { final DynamicForm form = new DynamicForm(); form.setDataSource(CountryDS.getInstance()); Window window = new Window(); window.setTitle("New Country"); window.setSize("600", "400"); window.addItem(form); IButton printButton = new IButton("Print preview"); printButton.addClickHandler(new ClickHandler(){ public void onClick(ClickEvent event) { Canvas.showPrintPreview(form); }}); window.addItem(printButton); window.draw(); } private static class CountryDS extends DataSource { private static CountryDS instance = null; public static CountryDS getInstance() { if (instance == null) { instance = new CountryDS("countryDS"); } return instance; } public CountryDS(String id) { setID(id); setRecordXPath("/List/country"); DataSourceIntegerField pkField = new DataSourceIntegerField("pk"); pkField.setHidden(true); pkField.setPrimaryKey(true); DataSourceTextField countryCodeField = new DataSourceTextField("countryCode", "Code"); countryCodeField.setRequired(true); DataSourceTextField countryNameField = new DataSourceTextField("countryName", "Country"); countryNameField.setRequired(true); DataSourceTextField capitalField = new DataSourceTextField("capital", "Capital"); DataSourceTextField governmentField = new DataSourceTextField("government", "Government", 500); DataSourceBooleanField memberG8Field = new DataSourceBooleanField("member_g8", "G8"); DataSourceTextField continentField = new DataSourceTextField("continent", "Continent"); continentField.setValueMap("Europe", "Asia", "North America", "Australia/Oceania", "South America", "Africa"); DataSourceDateField independenceField = new DataSourceDateField("independence", "Nationhood"); DataSourceFloatField areaField = new DataSourceFloatField("area", "Area (km˛)"); DataSourceIntegerField populationField = new DataSourceIntegerField("population", "Population"); DataSourceFloatField gdpField = new DataSourceFloatField("gdp", "GDP ($M)"); DataSourceLinkField articleField = new DataSourceLinkField("article", "Info"); setFields(pkField, countryCodeField, countryNameField, capitalField, governmentField, memberG8Field, continentField, independenceField, areaField, populationField, gdpField, articleField); setClientOnly(true); } } }
Comment