Results 1 to 4 of 4

Thread: [CLOSED] How to print gridpanel with data?

  1. #1
    Member
    Join Date
    Aug 2010
    Posts
    32

    [CLOSED] How to print gridpanel with data?

    How do I print gridpanel data with all display columns ?


    Code:
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Ext.IsAjaxRequest)
            {
                this.Store1.DataSource = new object[]
                {
                    new object[] {"3m Co", 71.72, 0.02, 0.03, "9/1 12:00am"},
                    new object[] {"Alcoa Inc", 29.01, 0.42, 1.47, "9/1 12:00am"},
                    new object[] {"Altria Group Inc", 83.81, 0.28, 0.34, "9/1 12:00am"}
                };
     
                this.Store1.DataBind();
            }
        }
    </script>
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Print </title>
         
       
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
             
            <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="company" />
                            <ext:RecordField Name="price" Type="Float" />
                            <ext:RecordField Name="change" Type="Float" />
                            <ext:RecordField Name="pctChange" Type="Float" />
                            <ext:RecordField Name="lastChange" Type="Date" DateFormat="n/j h:ia" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
             
            <ext:GridPanel
                ID="GridPanel1"
                runat="server"
                StoreID="Store1"
                StripeRows="true"
                Title="Array <span class="highlight">Grid</span>" 
                TrackMouseOver="true"
                Width="600" 
                Height="350"
                AutoExpandColumn="Company">
               <TopBar>
              <ext:Toolbar ID="Toolbar2" runat="server">
             <Items>
             <ext:Button ID="Button2" runat="server" Text="Print" Icon="Printer">
                                     <Listeners>
                                        <Click Handler="Print?" />
                                     </Listeners>
                    </ext:Button>
            </Items>
        </ext:Toolbar>
             </TopBar>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ColumnID="Company" Header="Company" Width="160" Sortable="true" DataIndex="company" />
                        <ext:Column Header="Price" Width="75" Sortable="true" DataIndex="price">
                            <Renderer Format="UsMoney" />
                        </ext:Column>
                        <ext:Column Header="Change" Width="75" Sortable="true" DataIndex="change"/>
                        <ext:Column Header="Change" Width="75" Sortable="true" DataIndex="pctChange"/>
                        <ext:Column Header="Last Updated" Width="85" Sortable="true" DataIndex="lastChange">
                            <Renderer Fn="Ext.util.Format.dateRenderer('m/d/Y')" />
                        </ext:Column>
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true"/>
                </SelectionModel>
              
            </ext:GridPanel>  
             
          
        </form>
    </body>
    </html>
    Last edited by Daniil; Sep 27, 2010 at 9:12 PM. Reason: [CLOSED]

  2. #2
    Ext.NET - Support Team Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    27,523
    Hi,

    To print a page please use javascript core
    Code:
    window.print()
    It prints the whole page.
    Respectively, there should be only GridPanel on the page to print this only.

    The alternative way is exporting GridPanel to a format like .csv, .xls, etc.

    An example how to export here
    http://examples1.ext.net/#/GridPanel...ort_Data_Ajax/
    Daniil
    Ext.NET, Inc.
    Support Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  3. #3
    Member
    Join Date
    Aug 2010
    Posts
    32
    Thanks Daniil,

    I have a multiple grid controls and some other control on page.
    Code:
    window.print()
    not suite to me.

    I was expecting any client side event to print store or gridpanel.

    Thanks
    Note: Solved

  4. #4
    Ext.NET - Support Team Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    27,523
    Here is the example how to print GridPanel.
    http://forums.ext.net/showthread.php...ll=1#post61460
    Daniil
    Ext.NET, Inc.
    Support Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

Similar Threads

  1. [CLOSED] Print functionality for GridPanel
    By speedstepmem3 in forum 1.x Premium Help
    Replies: 8
    Last Post: Oct 31, 2012, 6:52 PM
  2. Replies: 6
    Last Post: Feb 18, 2011, 2:12 PM
  3. [CLOSED] print
    By majestic in forum 1.x Premium Help
    Replies: 1
    Last Post: Sep 22, 2010, 2:53 PM
  4. Replies: 0
    Last Post: Jun 19, 2009, 4:18 AM
  5. Replies: 4
    Last Post: Nov 17, 2008, 8:16 AM

Tags for this Thread

Posting Permissions