Announcement

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

    how to open showPrintPreview() in a new window

    Hi,

    we are using smartgwt pro 3.0 version.

    we have used canvas.showPrintPreview(), it shows a popup window in the same window which covers old page.

    expectation is to open a printpreview window in a seprate tab of the browser not in the same tab or window.

    how can we implement this.


    Thanks in advance

    #2
    Use getPrintHTML() to obtain the HTML, and make sure the separate browser window has the same set of style sheets loaded.

    Comment


      #3
      Hi,

      sorry i not able to get.

      we have added the print preview action on button click as

      printImg.addClickHandler(new ClickHandler()
      {
      @Override
      public void onClick(ClickEvent event)
      {
      Canvas.showPrintPreview(reportDetailLayout);
      }
      }

      this Opens a popup window in the same window,

      how can we produce the printpreview in another new window.

      Comment


        #4
        The previous post gives the solution - if you're unfamiliar with how to open a new browser window with specific HTML, this is not a SmartGWT issue, and you can refer to core GWT documentation.

        Overall, if you're not already familiar with how to do this, you probably don't want to bother adding this behavior. It's a bad idea given pop-up blockers anyway.

        Comment


          #5
          How we can control the size of print preview window(height and width).

          I have overridden the getPrintHTML method of canvas to provide the customized html for print, but when I call Canvas.showPrintPreview(printCanvas); it covers up the whole window, I just want to set the width and height of the window.

          I hope I am clear this time.

          Thanks for your patience.

          Comment


            #6
            There is a signature of showPrintPreview that takes Window properties. Set the size via those Window properties.

            Comment


              #7
              Thanks, using Window properties I am able to set the width, height, canDragResize properties but unable to set "centerInPage" property.

              Am I doing something wrong here?

              Comment


                #8
                centerInPage is a method - set autoCenter: true instead

                Comment


                  #9
                  Thanks for the quick reply.

                  Comment


                    #10
                    Hi,

                    I just want to wrap the print html of HLayout in one div tag. How can I do that.

                    Few ways which I tried:
                    1. I followed the way gwt create the html for HLayout
                    I overwrite the getprintHTML for HLayout having 3 members something like this.
                    final HLayout reportComponent = new HLayout()
                    {
                    @Override
                    public String getPrintHTML(PrintProperties printProperties, PrintHTMLCallback callback)
                    {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.append("<div style=\"border-style:solid;border-width:1px;padding:10px;margin:5px;\">");
                    stringBuilder.append("<table width=\"100%\"><tbody><tr>");
                    for (Canvas canvas : this.getMembers())
                    {
                    stringBuilder.append("<td valign=\"top\">");
                    stringBuilder.append(canvas.getPrintHTML(printProperties, callback)).append("</td>");
                    }
                    stringBuilder.append("</tr> </tbody> </table> </div>");
                    return stringBuilder.toString();
                    }
                    };

                    For last two members I got html as null.

                    2. I did the same thing as above, instead of using this.getMembers() I used this.getChildren(), but the result was some.

                    Do we have any other easier way to this.

                    Thanks.

                    Comment


                      #11
                      getPrintHTML() has a callback parameter because generating printHTML for some components takes long enough that it has to be done asynchronously.

                      Use the callback parameter to be notified of completion.

                      No need to attempt to override getPrintHTML(), just call it. Also, rather than a simple DIV, we would recommend using HTMLFlow (no reason to get into low-level HTML issues).

                      Comment


                        #12
                        Thanks for the reply.

                        I am not clear on how to use the callback method to wrap the generated html in div tag.

                        I tried like this but this is not working,
                        reportComponent.getPrintHTML(null, new PrintHTMLCallback()
                        {
                        @Override
                        public void setHTML(String html)
                        {
                        html = "<div style=\"border-style:solid;border-width:1px;\">" + html + "</div>";
                        }
                        });

                        Comment


                          #13
                          This code does nothing but assign to a local variable "html" - what were you hoping for? To see a visual result, you would need to provide this HTML to an HTMLFlow via htmlFlow.setContents() (and draw it).

                          Comment


                            #14
                            Let me explain you my scneraio in detail.

                            I have one VLayout, which containes multiple HLyouts. Each of the HLayout have 3 members (Label, FacetChart, ListGrid), I wants to show the border for each of the HLayout. Now here how I can use HTMLFlow.

                            Comment


                              #15
                              HTMLFlow is a widget - a subclass of Canvas - so you use it like any other widget. If you want to display it in a Window, create a Window and make the HTMLFlow one of its items - as you would do with any other widget.

                              There are several samples of this in the Showcase.

                              Comment

                              Working...
                              X