[CLOSED] GridPanel print problem with RowExpander

  1. #1

    [CLOSED] GridPanel print problem with RowExpander

    Hello,

    I have a gridpanel with row expander, when clicking on print button only first row is exported. I tried the print function on the same grid but without row expander it worked fine. I sthere anu solution to print a gridpanel having row expander taking in consideration that I dont want the row expander to be appeared in the printed grid. Here is a test case with row expander, please try to remove the row expander plugin the print works fine.


    Test.aspx:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="FFMS.Test" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html >
    <html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=8,chrome=1">
    <ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />
    <ext:ResourcePlaceHolder runat="server" Mode="Style" />
        <title></title>
    
      <script>
    
          var handleRefresh = function () {
              App.GridPanel1.view.saveScrollState();
              App.direct.RefreshGrid({ success: handleScrollPos });
          }
    
          var handleScrollPos = function () {
              App.GridPanel1.view.restoreScrollState();
          }
    
    
          var template = '<span style="color:{0};">{1}</span>';
    
          var change = function (value) {
              return Ext.String.format(template, (value > 0) ? "green" : "red", value);
          }
    
          var pctChange = function (value) {
              return Ext.String.format(template, (value > 0) ? "green" : "red", value + "%");
          }
    
    
    
    
          //Add a new empty row to the grid and starts editing from the first field.
          var addEmployee = function () {
    
                              var grid = App.GridPanel1;
                              store = grid.getStore();
    
    
                              store.getSorters().removeAll(); // We have to remove sorting to avoid auto-sorting on insert
                              grid.getView().headerCt.setSortState(); // To update columns sort UI
    
                              store.insert(0, {});
    
                              grid.editingPlugin.startEdit(0, 0);
                      
    
          };
          //End addEmployee
    
    
          //Remove selected roe from the grid
          var removeEmployee = function () {
    
              var grid = App.GridPanel1,
           sm = grid.getSelectionModel();
    
              grid.editingPlugin.cancelEdit();
              grid.store.remove(sm.getSelection());
              if (grid.store.getCount() > 0) {
                  sm.select(0);
              }
    
          };
          //End removeEmployee
    
        </script>
    
    
        <style type="text/css">
            .myClass * {
                cursor: wait !important;
            }
        </style>
    
    
    </head>
    <body>
        <form id="form1" runat="server">
         <ext:ResourceManager ID="ResourceManager1" runat="server" ShowWarningOnAjaxFailure="false"/>
    
    
                <ext:GridPanel ID="GridPanel1" runat="server"  AutoScroll="true" Title="Print Grid Test" InvalidateScrollerOnRefresh="false" >
                   <Store>
                    <ext:Store ID="Store1" runat="server" PageSize="15">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="company" />
                                    <ext:ModelField Name="Price" Type="Float" />
                                    <ext:ModelField Name="change" Type="Float" />
                                    <ext:ModelField Name="Size" />
                                    <ext:ModelField Name="lastChange" Type="Date" DateFormat="M/d hh:mmtt" />
                                    <ext:ModelField Name="industry" />
                                    <ext:ModelField Name="desc" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                    <ColumnModel runat="server">
                        <Columns>
                            <ext:Column ID="CompanyColumn" runat="server" Text="Company" DataIndex="company" Width="400">
                            </ext:Column>
                            <ext:Column runat="server" Text="Price" DataIndex="Price" Width="250">
                            </ext:Column>
                            <ext:Column runat="server" Text="Change" DataIndex="change" Width="250">
                            <Renderer Fn="change" />
                            </ext:Column>
                            <ext:Column runat="server" Text="Size" DataIndex="Size" Width="250">
                            </ext:Column>
                            <ext:DateColumn runat="server" Text="Date" DataIndex="lastChange" Align="Center" Format="M/d hh:mmtt" Width="250">
                            </ext:DateColumn>
                               <ext:Column runat="server" Text="industry" DataIndex="industry" Width="250">
                            </ext:Column>
                        </Columns>
                    </ColumnModel>
                    <Plugins>
                        <ext:GridFilters runat="server" />
                         <ext:RowExpander ID="RowExpander1" runat="server">
    
                        <Template ID="Template1" runat="server">
                            <Html>
    							<right><p><b>Industry:</b> {industry}</p><br/></right>
    						</Html>
                        </Template>
                     
                    </ext:RowExpander>
                    </Plugins>
                    <TopBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:Button runat="server" Text="Print" Icon="Printer" Handler="this.up('grid').print();" />
                        </Items>
                    </ext:Toolbar>
                </TopBar>      
                    <BottomBar>
                        <ext:PagingToolbar runat="server"  RefreshHandler="handleRefresh();" >
                
                        </ext:PagingToolbar>
                    </BottomBar>
                </ext:GridPanel>
    
    
        </form>
    </body>
    </html>

    Test.aspx.cs:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Ext.Net;
    using System.Data;
    using System.Xml;
    
    namespace FFMS
    {
        public partial class FilterTest : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!X.IsAjaxRequest)
                {
                    this.Store1.DataSource = new object[]
                {
                    new object[] { "3m Co", 71.72, 0.02, "Large", "9/1 12:00am", "ليبلبيبللبيل" },
                    new object[] { "Alcoa Inc", 29.01, 0.42, "Extra-Large", "9/1 12:00am", "Manufacturing" },
                    new object[] { "Altria Group Inc", 83.81, 0.28, "small", "9/1 12:00am", "Manufacturing" },
                    new object[] { "American Express Company", 52.55, 0.01, "Large", "9/1 12:00am", "Finance" },
                    new object[] { "American International Group, Inc.", 64.13, 0.31, "Large", "9/1 12:00am", "Services" },
                    new object[] { "AT&T Inc.", 31.61, -0.48, "small", "9/1 12:00am", "Services" },
                    new object[] { "Boeing Co.", 75.43, 0.53, "Large", "9/1 12:00am", "Manufacturing" },
                    new object[] { "Caterpillar Inc.", 67.27, 0.92, "Large", "9/1 12:00am", "Services" },
                    new object[] { "Citigroup, Inc.", 49.37, 0.02, "Extra-Large", "9/1 12:00am", "Finance" },
                    new object[] { "E.I. du Pont de Nemours and Company", 40.48, 0.51, "Extra-Large", "9/1 12:00am", "Manufacturing" },
                    new object[] { "Exxon Mobil Corp", 68.1, -0.43, "small", "9/1 12:00am", "Manufacturing" },
                    new object[] { "General Electric Company", 34.14, -0.08, "small", "9/1 12:00am", "Manufacturing" },
                    new object[] { "General Motors Corporation", 30.27, 1.09, "Large", "9/1 12:00am", "Automotive" },
                    new object[] { "Hewlett-Packard Co.", 36.53, -0.03, "small", "9/1 12:00am", "Computer" },
                    new object[] { "Honeywell Intl Inc", 38.77, 0.05, "medium", "9/1 12:00am", "Manufacturing" },
                    new object[] { "Intel Corporation", 19.88, 0.31, "Large", "9/1 12:00am", "Computer" },
                    new object[] { "International Business Machines", 81.41, 0.44, "medium", "9/1 12:00am", "Computer" },
                    new object[] { "Johnson & Johnson", 64.72, 0.06, "small", "9/1 12:00am", "Medical" },
                    new object[] { "JP Morgan & Chase & Co", 45.73, 0.07, "small", "9/1 12:00am", "Finance" },
                    new object[] { "McDonald\"s Corporation", 36.76, 0.86, "Large", "9/1 12:00am", "Food" },
                    new object[] { "Merck & Co., Inc.", 40.96, 0.41, "Large", "9/1 12:00am", "Medical" },
                    new object[] { "Microsoft Corporation", 25.84, 0.14, "medium", "9/1 12:00am", "Computer" },
                    new object[] { "Pfizer Inc", 27.96, 0.4, "Large", "9/1 12:00am", "Medical" },
                    new object[] { "The Coca-Cola Company", 45.07, 0.26, "Large", "9/1 12:00am", "Food" },
                    new object[] { "The Home Depot, Inc.", 34.64, 0.35, "Large", "9/1 12:00am", "Retail" },
                    new object[] { "The Procter & Gamble Company", 61.91, 0.01, "small", "9/1 12:00am", "Manufacturing" },
                    new object[] { "United Technologies Corporation", 63.26, 0.55, "medium", "9/1 12:00am", "Computer" },
                    new object[] { "Verizon Communications", 35.57, 0.39, "Large", "9/1 12:00am", "Services" },
                    new object[] { "Wal-Mart Stores, Inc.", 45.45, 0.73, "Large", "9/1 12:00am", "Retail" }
                };
    
                    this.Store1.DataBind();
    
                  
    
                }
            }
    
    
    
            [DirectMethod]
            public void RefreshGrid()
            {
                 this.Store1.DataSource = new object[]
                {
                    new object[] { "New Company 1", 11.52, 0.1, "Large", "9/1 12:00am", "Manufacturing" },
                    new object[] { "New Company 2", 71.72, 0.02, "small", "9/1 12:00am", "Computer" },
                    new object[] { "New Company 3", 54.72, 5.4, "Extra-Large", "9/1 12:00am", "Manufacturing" },
                    new object[] { "3m Co", 71.72, 0.02, "Large", "9/1 12:00am", "Manufacturing" },
                    new object[] { "Alcoa Inc", 29.01, 0.42, "Extra-Large", "9/1 12:00am", "Manufacturing" },
                    new object[] { "Altria Group Inc", 83.81, 0.28, "small", "9/1 12:00am", "Manufacturing" },
                    new object[] { "American Express Company", 52.55, 0.01, "Large", "9/1 12:00am", "Finance" },
                    new object[] { "American International Group, Inc.", 64.13, 0.31, "Large", "9/1 12:00am", "Services" },
                    new object[] { "AT&T Inc.", 31.61, -0.48, "small", "9/1 12:00am", "Services" },
                    new object[] { "Boeing Co.", 75.43, 0.53, "Large", "9/1 12:00am", "Manufacturing" },
                    new object[] { "Caterpillar Inc.", 67.27, 0.92, "Large", "9/1 12:00am", "Services" },
                    new object[] { "Citigroup, Inc.", 49.37, 0.02, "Extra-Large", "9/1 12:00am", "Finance" },
                    new object[] { "E.I. du Pont de Nemours and Company", 40.48, 0.51, "Extra-Large", "9/1 12:00am", "Manufacturing" },
                    new object[] { "Exxon Mobil Corp", 68.1, -0.43, "small", "9/1 12:00am", "Manufacturing" },
                    new object[] { "General Electric Company", 34.14, -0.08, "small", "9/1 12:00am", "Manufacturing" },
                    new object[] { "General Motors Corporation", 30.27, 1.09, "Large", "9/1 12:00am", "Automotive" },
                    new object[] { "Hewlett-Packard Co.", 36.53, -0.03, "small", "9/1 12:00am", "Computer" },
                    new object[] { "Honeywell Intl Inc", 38.77, 0.05, "medium", "9/1 12:00am", "Manufacturing" },
                    new object[] { "Intel Corporation", 19.88, 0.31, "Large", "9/1 12:00am", "Computer" },
                    new object[] { "International Business Machines", 81.41, 0.44, "medium", "9/1 12:00am", "Computer" },
                    new object[] { "Johnson & Johnson", 64.72, 0.06, "small", "9/1 12:00am", "Medical" },
                    new object[] { "JP Morgan & Chase & Co", 45.73, 0.07, "small", "9/1 12:00am", "Finance" },
                    new object[] { "McDonald\"s Corporation", 36.76, 0.86, "Large", "9/1 12:00am", "Food" },
                    new object[] { "Merck & Co., Inc.", 40.96, 0.41, "Large", "9/1 12:00am", "Medical" },
                    new object[] { "Microsoft Corporation", 25.84, 0.14, "medium", "9/1 12:00am", "Computer" },
                    new object[] { "Pfizer Inc", 27.96, 0.4, "Large", "9/1 12:00am", "Medical" },
                    new object[] { "The Coca-Cola Company", 45.07, 0.26, "Large", "9/1 12:00am", "Food" },
                    new object[] { "The Home Depot, Inc.", 34.64, 0.35, "Large", "9/1 12:00am", "Retail" },
                    new object[] { "The Procter & Gamble Company", 61.91, 0.01, "small", "9/1 12:00am", "Manufacturing" },
                    new object[] { "United Technologies Corporation", 63.26, 0.55, "medium", "9/1 12:00am", "Computer" },
                    new object[] { "Verizon Communications", 35.57, 0.39, "Large", "9/1 12:00am", "Services" },
                    new object[] { "Wal-Mart Stores, Inc.", 45.45, 0.73, "Large", "9/1 12:00am", "Retail" }
                };
    
                    this.Store1.DataBind();
                
            }
    
    
        }
    }

    and Here are two screenshots of the print preview page: with RowExpander and without RowExpander
    Attached Thumbnails Click image for larger version. 

Name:	PrintWithoutRowExpander.jpg 
Views:	57 
Size:	101.7 KB 
ID:	24520   Click image for larger version. 

Name:	PrintWithRowExpander.png 
Views:	56 
Size:	41.4 KB 
ID:	24521  
    Last edited by fabricio.murta; Apr 10, 2016 at 1:00 PM. Reason: no user feedback for 7+ days
  2. #2
    Hello @Geovision!

    I see that historically it is not supported but... as per your requirement it can just be possible.

    I can think on two ways:
    1. keeping a copy of the grid, hidden, and use it as a base to print. Cumbersome and challenging to follow if the printed result depends on the shown/hidden and order in the columns that the user could change.
    2. Disable rowExpander before calling print and re-enable it afterwards -- must check if this is really feasible to just disable and enable on the run.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Grid Print with RowExpander Data
    By matrixwebtech in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: May 04, 2015, 9:43 PM
  2. Grid Print problem
    By SebasVT in forum 2.x Help
    Replies: 9
    Last Post: Nov 05, 2014, 4:08 PM
  3. Print Tree Panel Icons visibility Problem
    By ITECH-Developer in forum 1.x Help
    Replies: 0
    Last Post: Sep 01, 2013, 8:16 AM
  4. Print gridpanel with grouping
    By PetrSnobelt in forum 2.x Help
    Replies: 0
    Last Post: May 13, 2013, 1:32 PM
  5. Replies: 6
    Last Post: Feb 18, 2011, 2:12 PM

Posting Permissions