[CLOSED] Print a grid panel javascript error

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Print a grid panel javascript error

    Hello,

    I need your help. I have a grid panel with a toolbar that contains a print button.

    When i click on the button print i get the following error:
    Microsoft JScript runtime error: Unable to set value of the property 'innerHTML': object is null or undefined

    When click then continue the new page opens up but empty. if i click print again. the grid panel data shows up in the printpage and i can print at this point.


    I found some code on forums to help implemt this and this how the sample code looks like:

    Please note that i had to comment the last line of code of the function printGrid to get some partial result. when it is uncommented.

    My browser is IE9.

    1) Here is the Code Behind:

            protected void Page_Load(object sender, EventArgs e)    
            {      
                
                    if (!X.IsAjaxRequest)
                    {
                        this.BindData();
                    }
    
                }
            }
            protected void MyData_Refresh(object sender, StoreReadDataEventArgs e)
            {
                this.BindData();
            }
    
            protected void BindData()
            {
                    var storeactive = this.gpactive.GetStore();
                    storeactive.DataSource = this.Data;            
                    storeactive.DataBind(); 
            }
    
            }
            private object[] Data
            {
                get
                {
                    return 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" },                
                                    new object[] { "American Express Company", 52.55, 0.01, 0.02, "9/1 12:00am" },                
                                    new object[] { "American International Group, Inc.", 64.13, 0.31, 0.49, "9/1 12:00am" },               
                                };
                }
            }

    2) My Javascript is like this page is like this:

    function printGrid(grid, window) {
                window.show();
                var bd = window.getBody();
                bd.document.body.innerHTML = grid.body.dom.innerHTML;
                bd.document.getElementById(grid.view.el.id).style.height = "auto";
    //            bd.document.getElementById(grid.view.scroller.id).style.height = "auto";
            }
    3) My ASpx page is like this:

    <ext:Hidden ID="FormatTypeIncoming" runat="server" />
                                <ext:GridPanel ID="gpIncoming" runat="server" Title="Incoming Pipeline / Declined Deals">
                                    <Store>
                                        <ext:Store ID="gpincomingstore" runat="server" OnReadData="MyData_Refresh" OnSubmitData="StSubmitIncoming"
                                            PageSize="10" RemoteSort="true">
                                            <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="pctChange" Type="Float" />                            
                                                        <ext:ModelField Name="lastChange" Type="Date"/>
                                                  </Fields>
                                                </ext:Model>
                                            </Model>
                                            <Sorters>
                                                <ext:DataSorter Property="company" Direction="ASC" />
                                            </Sorters>
                                        </ext:Store>
                                    </Store>
                                    <TopBar>
                                        <ext:Toolbar ID="ToolbarIncoming" runat="server">
                                            <Items>
                                                <ext:ToolbarFill ID="ToolbarFillIncoming" runat="server" />
                                                <ext:Button ID="btnExcelIncoming" runat="server" Text="To Excel" Icon="PageExcel">
                                                    <Listeners>
                                                        <Click Handler="submitValueIncoming(#{gpIncoming}, #{FormatTypeIncoming}, 'xls');" />
                                                    </Listeners>
                                                </ext:Button>
                                                <ext:Button ID="btnPrintgpinitial" runat="server" Text="Print" Icon="Printer" OnClientClick="printGrid(#gpIncoming},# {PrintWindow});">
                                                 </ext:Button>
                                            </Items>
                                        </ext:Toolbar>
                                    </TopBar>
                                   <ColumnModel ID="ColumnModel1" runat="server">            
                                        <Columns>                
                                            <ext:Column ColumnID="Company" Header="Company" DataIndex="company" />                
                                            <ext:Column Header="Price" DataIndex="price">                                      
                                                <Renderer Format="UsMoney" />                
                                           </ext:Column>                
                                           <ext:Column ColumnID="Change" Header="Change" DataIndex="change">                    
                                            <Renderer Fn="change" />                
                                           </ext:Column>                
                                           <ext:Column Header="Change" DataIndex="pctChange">                    
                                            <Renderer Fn="pctChange" />                
                                           </ext:Column>                
                                           <ext:DateColumn Header="Last Updated" DataIndex="lastChange" />            
                                           </Columns>        
                                    </ColumnModel>    
                                </ext:GridPanel>
                                <ext:Window ID="PrintWindow" runat="server" Width="1200" Height="400" Hidden="true">
                                    <TopBar>
                                        <ext:Toolbar ID="Toolbar1" runat="server">
                                            <Items>
                                                <ext:Button ID="Button1" runat="server" Text="Print" Icon="Printer" OnClientClick="#{PrintWindow}.getBody().print();" />
                                            </Items>
                                        </ext:Toolbar>
                                    </TopBar>
                                    <Loader runat="server" Url="Pageprint.aspx" Mode="Frame"></Loader>
                                </ext:Window>
    4) Here is the print page aspx:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Print Page</title>
        <link rel="stylesheet" type="text/css" href="/extjs/resources/css/ext-all-embedded-css/ext.axd" />
    </head>
    <body>
    </body>
    </html>
    Last edited by Daniil; Nov 05, 2012 at 3:42 PM. Reason: [CLOSED]
  2. #2

    error

    I can pinpoint the error it breaks in the javascript function line here:
    var bd = window.getBody();

    Please help
  3. #3
    Hi @otouri,

    Welcome to Ext.NET!

    This code
    OnClientClick="printGrid(#gpIncoming},# {PrintWindow});"
    Is there a space between "#" and "{", right? Please remove.
  4. #4
    Hello,
    Thank you for your answer.
    I double checked and this what I have on my code:
    OnClientClick="printGrid(#{gpInitial}, #{PrintWindow});"

    i have no space. Probably the space you see in the post is due to when i was formating it.

    Thank you,
  5. #5
    Quote Originally Posted by otouri View Post
    I can pinpoint the error it breaks in the javascript function line here:
    var bd = window.getBody();
    What is the error?

    Is the issue reproducible with the latest sources from SVN?
    http://svn.ext.net/premium/branches/2.1/
  6. #6
    This is
    Microsoft JScript runtime error: Unable to set value of the property 'innerHTML': object is null or undefined.

    What i am using is EXT.NET 2.0.

    How do I get 2.1?
  7. #7
    Quote Originally Posted by otouri View Post
    This is
    Microsoft JScript runtime error: Unable to set value of the property 'innerHTML': object is null or undefined.
    Thank you. Though I am still unable to reproduce it.

    Quote Originally Posted by otouri View Post
    How do I get 2.1?
    The link is in my previous post.

    You need SVN credentials. They had to be emailed to you when you got a Premium Support Subscription. Please check the Inbox. If they are lost, please send a request including your forum name to:
    support@object.net
    Last edited by Daniil; Nov 01, 2012 at 6:15 AM.
  8. #8
    I got the SVn Credentials.
    Could please post the path of the dlls i need. For this project I am using the following dlls:
    Ext.Net
    Ext.ney.Utilities
    Newtonsoft.Json
    Transformer.NET.
    Thank you,
  9. #9
    There are no dlls. Please checkout the whole sources and build.
  10. #10
    how do i download the source if i only see hyperlinks. what FTP tool would you recommend to access svn
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 2
    Last Post: May 30, 2011, 5:53 AM
  2. Replies: 6
    Last Post: Feb 18, 2011, 2:12 PM
  3. [CLOSED] [1.0] Panel collapse from javascript giving error
    By vedagopal2004 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 08, 2010, 6:23 AM
  4. Replies: 2
    Last Post: Jul 01, 2009, 1:06 PM
  5. IE7 Update Panel javascript error with Mono
    By cristianpsg in forum Bugs
    Replies: 0
    Last Post: Apr 30, 2009, 1:27 PM

Tags for this Thread

Posting Permissions