Announcement

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

    PrintPreview within a Window

    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 :

    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);  
    	    }  
    	}  
    }
    Thank you !

    #2
    What oa your SmartGWT version? Upgrade
    to the latest if you haven't already.

    Are you seeing JavaScript errors? If so, post the stack trace
    logged to the Developer Console in IE.

    Comment


      #3
      I have the version 1.3 revision 782.

      I didn't get javascript errors but I got the error : WARNING: No file found for: /testprintpreviewwindow/sc/system/helpers/printFrame.html in eclipse.

      Comment


        #4
        This was an oversight in 1.3 with the module reorganization. This will be fixed in the next release / SVN but for now please add this to your module file :

        <inherits name="com.smartgwt.tools.SmartGwtTools"/>
        Last edited by smartgwt.dev; 5 Oct 2009, 12:10.

        Comment


          #5
          It works ! Thank you !

          By the way, I saw that the method Canvas.showPrintPreview returns something. but when I tried to catch that object I got null. So, I wonder if it is possible that you return a PrintWindow that we can customize.

          Thank you.

          Comment


            #6
            It is possible to drag PrintPreview Window

            Hello All,

            I am using SmartGWT 1.3 with GWT 1.7.

            I can see print preview dialog, but it is possible to drag it so, that the print button disappears. Is it possible to make the print preview window not draggble?
            I think that there are lot of users, who can drag it somewhere and loose the print button at all.....

            Thank you

            Comment


              #7
              print preview dialog dragging

              Originally posted by smikesh
              Hello All,

              I am using SmartGWT 1.3 with GWT 1.7.

              I can see print preview dialog, but it is possible to drag it so, that the print button disappears. Is it possible to make the print preview window not draggble?
              I think that there are lot of users, who can drag it somewhere and loose the print button at all.....

              Thank you
              These few lines should stop the print preview dialog from dragging

              Code:
               
              	Object[] printArr = new Object[] {
              
              	      //your data to print	 
              	};	
              
              
              	Window window = new Window();			
              	window.setCanDragReposition(false);
              	Canvas.showPrintPreview(printArr, null, "Print Preview", null, window, "Print") ;

              Comment


                #8
                Hi,
                We have a listgrid and a menu item is added to it for print preview and it shows blank screen and messes the list grid contents on firefox 3.6 and ie,
                smart gwt 2.5.

                Code:
                Canvas.showPrintPreview(listgrid)
                also tried:
                Code:
                Canvas.showPrintPreview(components, null, "Print Preview", null, new Window(), "Print");
                Both does not work in some case. Mostly it works. But sometimes a blank print preview screen is shownand messing the list grid contents.

                Attached is the screenshot.

                It was observed in firebug that the table visibility is set to hidden for some reason.When we remove it the print content appears..

                I suspect there is some special character causing this issue. but not sure..
                Any suggestions are welcome.
                thanks
                Sandeep
                Attached Files

                Comment

                Working...
                X