Uncaught TypeError: Cannot read property 'items' of null

  1. #1

    Uncaught TypeError: Cannot read property 'items' of null

    Attached Thumbnails Click image for larger version. 

Name:	ExtNet-ItemsNull.png 
Views:	37 
Size:	80.6 KB 
ID:	6824  
  2. #2

    The same issue

    Hello!

    I have faced the same issue (at least with the same error message).
    I do not know, how to resolve it properly, but it seems, that the following control causes such behavior: PagingToolbar. Can you please try to remove it temporary from markup and reproduce this issue?

    Btw, it would be nice to get response from support team on how to workaround this!
  3. #3
    We need simple runable test case reproduces the issue. The code from first post is not runable and contains many code is not related with the issue
  4. #4
    Quote Originally Posted by Vladimir View Post
    We need simple runable test case reproduces the issue. The code from first post is not runable and contains many code is not related with the issue
    Sample is based on https://examples2.ext.net/#/XRender/...UpdateContent/
    Default.aspx:
    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Collections.Generic"%>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        UserControl currentUC;
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(CurrentControl.Text))
            {
                this.LoadUserControl(CurrentControl.Text);
            }
        }
    
        private void LoadUserControl(string num, bool update = false)
        {
            if (update && currentUC != null)
            {            
                this.Panel1.ContentControls.Clear();
            }        
            
            currentUC = (UserControl)this.LoadControl(string.Format("UserControl{0}.ascx", num));
            currentUC.ID = "UC" + num;
            this.Panel1.ContentControls.Add(currentUC);
            
            if (update)
            {
                CurrentControl.Text = num;
                this.Panel1.UpdateContent();
            }
        }
    
        protected void Button1_Click(object sender, DirectEventArgs e)
        {
            this.LoadUserControl("1", true);
        }
    
        
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Update Controls and Content during a DirectEvent - Ext.NET Examples</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <h1>Update Controls and Content during a DirectEvent</h1>
            
            <h3>Load UserControls</h3>
            
            <ext:Hidden ID="CurrentControl" runat="server" />
    
            <ext:Panel 
                ID="Panel1" 
                runat="server" 
                Title="User Controls" 
                Width="500" 
                Height="700"
                BodyPadding="5">
                <TopBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:Button 
                                ID="Button1" 
                                runat="server" 
                                Text="Load 1"
                                OnDirectClick="Button1_Click" 
                                />
                        </Items>
                    </ext:Toolbar>
                </TopBar>
            </ext:Panel>
        </form>
    </body>
    </html>
    UserControl1.ascx:
    <%@ Control Language="C#" %>
    
    <script runat="server">
        
    
        private void BindGrid(object sender, DirectEventArgs e)
        {
            Store store = this.GridPanel1.GetStore();
    
            store.DataSource = new Company[]
                {
                    new Company{Name = "3m Co"},
                    new Company{Name = "Alcoa Inc"},
                    new Company{Name = "Altria Group Inc"},
                };
            store.DataBind(); 
        }
        
        public class Company
        {
            public string Name { get; set; }
        }
    
    </script>
    
    
    <h1>№1</h1>
    <ext:Label ID="Label1" runat="server" Text="I am User control №1" />
    <br />
    <ext:Button ID="Button1" runat="server" Text="User control №1: Ext.Net button" OnDirectClick="BindGrid" />
    
    
    <ext:GridPanel
                ID="GridPanel1"
                runat="server" 
                Title="Array Grid" 
                Width="700">
                <Store>
                    <ext:Store ID="Store1" runat="server" PageSize="10">
                        <Model>
                            <ext:Model ID="Model1" runat="server">
                                <Fields>
                                    <ext:ModelField Name="Name" />
                                </Fields>
                            </ext:Model>
                        </Model>                  
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ID="Column1" runat="server" Text="Company" DataIndex="Name"  />
                    </Columns>
                </ColumnModel>
                <View>
                    <ext:GridView ID="GridView1" runat="server" StripeRows="true" />                   
                </View>            
                <BottomBar>
                    <ext:PagingToolbar ID="PagingToolbar1" runat="server" />
                </BottomBar>
            </ext:GridPanel>
    How to reproduce an issue:
    1. Launch /Default.aspx
    2. Click "Load 1" button
    3. Click "Load 1 " button again
    4. Expected: user control should reload correctly
    5. Actual result: console error message appear: "Uncaught TypeError: Cannot read property 'items' of null "


    Commenting out the line 58 in UserControl1.ascx :
    <ext:PagingToolbar ID="PagingToolbar1" runat="server" />
    makes this example workable.

    Summary:
    Including ext:PagingToolbar control makes impossible to use GridPanel withing dynamically loaded user control.
    Last edited by Bal323; Sep 06, 2013 at 11:11 AM.
  5. #5
    I cannot reproduce the issue with latest code, may be it is fixed already. Please wait next public release (should be soon) and retest
  6. #6
    Quote Originally Posted by Vladimir View Post
    I cannot reproduce the issue with latest code, may be it is fixed already. Please wait next public release (should be soon) and retest
    I have included Ext.net reference via Nuget, version 2.2.0.1. Can you please verify against this version?
  7. #7

    Solved

    Vladimir, thank for your support. Updated to last version without NuGet and solved my problem.

    You can close this post.

    Thank you again!

Similar Threads

  1. Replies: 1
    Last Post: Jun 05, 2013, 11:01 AM
  2. Replies: 4
    Last Post: May 30, 2013, 1:36 PM
  3. Replies: 2
    Last Post: Apr 10, 2012, 12:08 PM
  4. [CLOSED] Uncaught TypeError: Object #<Object> has no method '***'
    By Sevilay Tanış in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Mar 27, 2012, 4:44 PM
  5. [CLOSED] Read/Write Values to CustomConfig Items
    By HOWARDJ in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 19, 2010, 7:03 PM

Tags for this Thread

Posting Permissions