1. #1
    Sencha User ITS_luka's Avatar
    Join Date
    Aug 2011
    Location
    Tbilisi, Georgia
    Posts
    19
    Vote Rating
    0
    ITS_luka is on a distinguished road

      0  

    Question Unanswered: How to make a print Button?

    Unanswered: How to make a print Button?


    I want to make a print button to print values of fields on a page.

  2. #2
    Sencha User PhiLho's Avatar
    Join Date
    Nov 2011
    Location
    Near Paris, France
    Posts
    139
    Answers
    2
    Vote Rating
    1
    PhiLho is on a distinguished road

      0  

    Default


    To my knowledge, there is no simple way...
    And it depends on what you want to print.

    I think there is a way for JavaScript to request to the browser to print out the current page. This is probably not what you want.

    Another way is to create on the server side a document laying out the information you need to print. It might be a simple HTML file, and maybe you can display it in a popup window and ask the browser to print it out. It can be problematic with popup blockers... Or it might be a PDF file made with iText, for example, and then the users can download it and print it themselves.

  3. #3
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    411
    Answers
    20
    Vote Rating
    21
    icfantv will become famous soon enough icfantv will become famous soon enough

      0  

    Default


    Here's what I did for starters:

    Code:
              TextButton printButton = new TextButton("Print", Images.INSTANCE.print());
              printButton.addSelectHandler(new SelectHandler() {
    
                @Override
                public void onSelect(SelectEvent event) {
                  Window.print();
                }
              });
    I think this executes javascript:print() and prints the browser window. The Images class is simply my image provider class.

    I think Philho is right though, if you want a formatted page to be printed, you'll need to format the data you want to print, slap that in some type of pop-up window and then call Window.print inside that pop-up window.

    HTH.

    --adam

  4. #4
    Sencha User ITS_luka's Avatar
    Join Date
    Aug 2011
    Location
    Tbilisi, Georgia
    Posts
    19
    Vote Rating
    0
    ITS_luka is on a distinguished road

      0  

    Default


    OK thank you. I'v done it

Thread Participants: 2