Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    TileGrid PrintPreview Problem

    Versions: smartGWT: 2.5 / FireFox 6

    I have a tilegrid for which I want to generate a PrintPreview. I only get a part of the grid however, even when I use
    Code:
    ...
    printing = true;
    final ResultSet resultSet = tileGrid.getResultSet();
    int totalRows = resultSet.getLength();
    resultSet.getRange(1, totalRows);
    resultSet.addDataArrivedHandler(new DataArrivedHandler() {
    			public void onDataArrived(DataArrivedEvent event) {
    				logger.log(Level.INFO, "All data arrived...");
    				if (printing) {
    					Canvas.showPrintPreview(tileGrid);
    					printing = false;
    				}
    			}
    		});
    ...
    the only way I can get things to print my complete TileGrid is by resizing my tiles to remove the scrollbars (unzooming), refetching data with the current criteria, printing and finally restoring the original tile size.
    Any thoughts on a better way to solve this problem?
    Last edited by Hannes; 22 Nov 2011, 03:04.

    #2
    I've made a test case, tested on:
    - SC_SNAPSHOT-2011-08-02/PowerEdition Deployment (built 2011-08-02)
    - GWT 2.1.0
    - FireFox 8

    EntryPoint class:
    Code:
    package test.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.widgets.Button;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.layout.VLayout;
    import com.smartgwt.client.widgets.tile.TileGrid;
    
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    public class Test implements EntryPoint {
    	
    	private VLayout vLayout;
    	private TileGrid tileGrid;
    	private Button printButton;	
    	
    	public void onModuleLoad() {
    		vLayout = new VLayout();
    		
    		createTileGrid();
    		createButton();
    		
    		vLayout.draw();
    	}
    	
    	private void createTileGrid() {
    		DataSource ds = DataSource.get("Content");
    		
    		tileGrid = new TileGrid();
    		tileGrid.setWidth(400);
    		tileGrid.setHeight(200);
    		tileGrid.setDataSource(ds);
    		tileGrid.setAutoFetchData(true);
    		
    		vLayout.addMember(tileGrid);
    	}
    
    	private void createButton() {
    		printButton = new Button("Show Print preview");
    		printButton.addClickHandler(new ClickHandler() {			
    			@Override
    			public void onClick(ClickEvent event) {
    				Canvas.showPrintPreview(tileGrid);
    			}
    		});
    		
    		vLayout.addMember(printButton);
    	}
    	
    }
    DataSource
    Code:
    <DataSource ID="Content" serverType="sql" tableName="content">
    	<fields>
    		<field primaryKey="true" type="sequence" name="cntn_pk" hidden="true" export="false"></field>
    		<field title="id" type="text" name="cntn_id"></field>
    		<field title="barcode" type="text" name="cntn_barCode"></field>
    		<field title="Location" type="integer" name="cntn_fk_location"></field>
    	</fields>
    </DataSource>
    When using f.i. 75 records, 18 tiles are visible and the other ones can be viewed by the scrollbar. But when clicking "Show Print Preview", there are only 37 tiles visible.
    Is it possible to get all the tiles printed?

    Also if you scroll down the TileGrid and click "Show Print Preview" the following error occurs:
    Code:
    16:49:22.898 [ERROR] [test] Uncaught exception escaped
    
    com.google.gwt.core.client.JavaScriptException: (TypeError): _1 is undefined
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:237)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
        at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
        at com.smartgwt.client.widgets.Canvas.showPrintPreview(Canvas.java)
        at test.client.Test$1$1.onDataArrived(Test.java:60)
        at com.smartgwt.client.data.events.DataArrivedEvent.dispatch(DataArrivedEvent.java:96)
        at com.smartgwt.client.data.events.DataArrivedEvent.dispatch(DataArrivedEvent.java:1)
        at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
        at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
        at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
        at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
        at com.smartgwt.client.core.BaseClass.fireEvent(BaseClass.java:485)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
        at com.smartgwt.client.data.ResultSet.dataArrived(ResultSet.java)
        at test.client.Test$1.onClick(Test.java:65)
        at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.java:99)
        at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.java:1)
        at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
        at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
        at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
        at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
        at com.smartgwt.client.widgets.BaseWidget.fireEvent(BaseWidget.java:67)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
        at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
        at java.lang.Thread.run(Thread.java:662)

    Comment


      #3
      TileGrids and ListGrids will both print only loaded records. You can force all records to be loaded with tileGrid.dataFetchMode.

      As far as the crash, please retest with the latest patched version (smartclient.com/builds) and let us know whether it's still reproducible.

      Comment


        #4
        Thanks for the quick reply.

        With tileGrid.dataFetchMode.LOCAL all records are fetched (here f.i. 80 records), but print preview still not prints all the tiles...
        Code:
        === 2012-01-11 11:57:32,540 [l0-5] DEBUG RPCManager - Request #1 (DSRequest) payload: {
            criteria:{
            },
            operationConfig:{
                dataSource:"Content",
                operationType:"fetch",
                textMatchStyle:"substring"
            },
            componentId:"isc_TileGrid_0",
            appID:"builtinApplication",
            operation:"Content_fetch",
            oldValues:null
        }
        === 2012-01-11 11:57:32,556 [l0-5] INFO  IDACall - Performing 1 operation(s)
        === 2012-01-11 11:57:32,556 [l0-5] DEBUG AppBase - [builtinApplication.Content_fetch] No userTypes defined, allowing anyone access to all operations for this application
        === 2012-01-11 11:57:32,571 [l0-5] DEBUG AppBase - [builtinApplication.Content_fetch] No public zero-argument method named '_Content_fetch' found, performing generic datasource operation
        === 2012-01-11 11:57:32,571 [l0-5] INFO  SQLDataSource - [builtinApplication.Content_fetch] Performing fetch operation with
        	criteria: {}	values: {}
        === 2012-01-11 11:57:32,571 [l0-5] INFO  SQLWhereClause - [builtinApplication.Content_fetch] empty condition
        === 2012-01-11 11:57:32,571 [l0-5] INFO  SQLDataSource - [builtinApplication.Content_fetch] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause
        === 2012-01-11 11:57:32,727 [l0-5] DEBUG PoolableSQLConnectionFactory - [builtinApplication.Content_fetch] Initializing SQL config for 'Mysql' from system config - using DataSource:  com.mysql.jdbc.jdbc2.optional.MysqlDataSource
        === 2012-01-11 11:57:32,915 [l0-5] DEBUG PoolableSQLConnectionFactory - [builtinApplication.Content_fetch] Returning pooled Connection
        === 2012-01-11 11:57:32,915 [l0-5] INFO  SQLDriver - [builtinApplication.Content_fetch] Executing SQL query on 'Mysql': SELECT content.cntn_barCode, content.cntn_id, content.cntn_pk, content.cntn_fk_location FROM content WHERE ('1'='1')
        === 2012-01-11 11:57:32,930 [l0-5] INFO  DSResponse - [builtinApplication.Content_fetch] DSResponse: List with 80 items
        With version SC_SNAPSHOT-2012-01-09_v8.1p/PowerEdition Deployment 2012-01-09 the previous crash also still occurs.

        Comment

        Working...
        X