Hybrid View

  1. #1
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    78
    Vote Rating
    1
    kmanuel@entausa.com is on a distinguished road

      0  

    Post Grouped Grid Printer

    Grouped Grid Printer


    I couldn't find a print function for grouped grids, so I made one. This may not be (isn't) the most elegant or efficient way to go about this, but I managed to make it work with Ext 4.0.7 and 4.1.0. I only have done initial testing in Chrome and FF and it suits our needs. I hope someone else finds it useful.

    Printer for Grouped grids with or without summary totals.
    Will open a new window with the results which can be printed by the browser.
    Preserves hidden columns, widths, column order, and collapse status.

    GroupedPrinter.txt

  2. #2
    Sencha User
    Join Date
    Oct 2010
    Posts
    5
    Vote Rating
    0
    Candeloro is on a distinguished road

      0  

    Default


    I am testing your code
    this is my view for grid
    Code:
    Ext.define('LayoutTest.view.ElencoConsegneRitiri', {
        extend: 'Ext.grid.Panel',
        alias:    'widget.elencoconsegneritiri',
        
        id:'gridAgendeConsegneRitiri',
        title : 'Agende',
        multiSelect: true,
        selType: 'rowmodel',
        plugins: [
                      Ext.create('Ext.grid.plugin.RowEditing', {
                        saveBtnText : 'Salva riga',
                        cancelBtnText : 'Annulla ',
                        clicksToEdit: 2
                          })    
                  ],
    
        initComponent: function() {
    
            var groupingFeature = Ext.create('Ext.grid.feature.GroupingSummary',{
                groupByText: 'Raggruppa per questo campo',
                showGroupsText: 'Raggruppa',
                startCollapsed: false,
                groupHeaderTpl: '{name} ({rows.length} Pratic{[values.rows.length > 1 ? "he" : "a"]})'
            });
     
            
         
            
            this.features = [groupingFeature];
            this.store = 'ConsegneRitiriPratiche';
            this.columns = [
    
                {header: 'Id',                dataIndex: 'Id',                   xtype:'numbercolumn',    hidden:true,  width: 80,    hideable:true, sortable: true,     resizable: false, groupable:false,    format:'',             align:'right',  flex: 0},
                {header: 'Pratica',            dataIndex: 'IdPra',               xtype:'numbercolumn',    hidden:false, width: 60,    hideable:true, sortable: true,     resizable: false, groupable:false,    format:'',             align:'right',  flex: 0},
                
                {header: 'Stato',           dataIndex: 'IdStatoAttivita',     xtype:'gridcolumn',        hidden:false, width: 90,    hideable:true, sortable: true,     resizable: false, groupable:true,    format:'',             align:'left',      flex: 0, renderer :Ext.getStore('StatoDettagliConsolati').getStatoDettaglio},
                        
            ];
    
            this.tbar  = [{
             
                text: 'Stampa Griglia',
                iconCls: 'icon-print',
                scope:this,
                handler : function(){
    //               Ext.ux.grid.Printer.printAutomatically = false;
    //               Ext.ux.grid.Printer.print(this);
     
                   Ext.ux.grid.GroupedPrinter.print(this);
                }
            }
          ];
            
            this.callParent(arguments);
    
        }
    
    });
    I have the error Ext.ux.groupedGridPrinter Argument 'grid' was not an HTML element or a string Id

    If I use the Ext.ux.grid.Printer.print all is Ok
    Where is my error?

  3. #3
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    78
    Vote Rating
    1
    kmanuel@entausa.com is on a distinguished road

      0  

    Default


    Try this. I added a check
    Code:
            } else if (grid instanceof Ext.grid.Panel && grid.body) {
                gridElement = grid.body.dom;
            }
    GroupedPrinter.txt

  4. #4
    Sencha User
    Join Date
    Oct 2010
    Posts
    5
    Vote Rating
    0
    Candeloro is on a distinguished road

      0  

    Default


    Thank you.
    In my grid there are some columns hiddens, this make a bad align in the print

  5. #5
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    78
    Vote Rating
    1
    kmanuel@entausa.com is on a distinguished road

      0  

    Default


    Can you post screenshots and possibly a full example with static data?

  6. #6
    Sencha User
    Join Date
    Oct 2010
    Posts
    5
    Vote Rating
    0
    Candeloro is on a distinguished road

      0  

    Default


    I post one example ..you can see the print of the grid also without grupping,
    First column is hidden:
    Tanks
    Attached Files

Thread Participants: 1

Tags for this Thread