[CLOSED] Uncaught TypeError: Cannot read property 'items' of null

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Uncaught TypeError: Cannot read property 'items' of null

    in expander event , code as follow:
     <Plugins>
                                    <ext:RowExpander ID="RowExpander1" runat="server" ExpandOnDblClick="true" ExpandOnEnter="true" IsDynamic="true" SingleExpand="true" ScrollOffset="10">
                                        <Loader ID="Loader1" runat="server" DirectMethod="App.direct.GetGrid" Mode="Component">
                                            <LoadMask ShowMask="true" />
                                            <Params>
                                                <ext:Parameter Name="Month" Value="this.record.data.Month" Mode="Raw" />
                                                <ext:Parameter Name="gridType" Value="App.cbxZygs.getValue()" Mode="Raw" />
                                            </Params>
                                        </Loader>
                                        <Renderer Handler=" if (record.data.Digest !== '本月合计')  { return false; }" />
                                    </ext:RowExpander>
                                </Plugins>
    behind code as follow:
    [DirectMethod]
            public string GetGrid(Dictionary<string, string> parameters)
            {
                string Month = parameters["Month"];
                string gridType = parameters["gridType"];
    
    
                GridPanel grid = new GridPanel
                {
                    ID = "gridpanel_" + parameters["Month"],
                    EnableColumnHide = false,
                    AutoScroll = true,
                    StyleSpec = "border:solid 2px #3892D3",
                    SortableColumns = false,
                    Height = 370,
                    Store ={                    
                        new Store{                        
                            ID="store_"+parameters["Month"],
                            Model={
                                new Model{
                                    Fields={
                                        new ModelField("VouchId"),
                                        new ModelField("Month"),
                                        new ModelField("VouchNo"),
                                        new ModelField("Digest"),
                                        new ModelField("Yedj"),
                                        new ModelField("Yehl"),
                                        new ModelField("Jfsl"),
                                        new ModelField("Jfwb"),
                                        new ModelField("Jfje"),
                                        new ModelField("Dfsl"),
                                        new ModelField("Dfwb"),
                                        new ModelField("Dfje"),
                                        new ModelField("Direction"),
                                        new ModelField("Yesl"),
                                        new ModelField("Yewb"),
                                        new ModelField("Yeje")
                                    }
                                }
                            },
                            Parameters={
                                new StoreParameter{Name="Year",Value="2002",Mode=ParameterMode.Value},
                                new StoreParameter{Name="DMonth",Value=Month,Mode=ParameterMode.Value},
                                new StoreParameter{Name="AccCode",Value="App.treePanelZflz.getSelectionModel().getSelection().length==0?'':App.treePanelZflz.getSelectionModel().getSelection()[0].data['Ccode']", Mode=ParameterMode.Raw},
                                new StoreParameter{Name="isContainWjz",Value="App.cbxIfContainWJZ.value",Mode=ParameterMode.Raw},
                                new StoreParameter{Name="isZzQueryMxz",Value="1",Mode=ParameterMode.Value}
                            },
                            Proxy={
                                new AjaxProxy(){
                                    Url="../BBAshx/ZzmxzBB.ashx",
                                    Reader={
                                        new JsonReader{
                                            Root="data"
                                        }
                                    }
                                }
                            },                       
                            PageSize=10,                        
                        }
                    },
                    ColumnModel =
                    {
                        Columns ={
                           new Column{ItemID="Day",Text="日期",DataIndex="Month",Width=100},
                            new Column{ItemID="VouchNo",Text="凭证字号",DataIndex="VouchNo",Width=100},
                           new Column{ItemID="Digest",Text="摘要",DataIndex="Digest",Width=250},
                            new Column{ItemID="Dj",Text="单价",DataIndex="Yedj",Align=Alignment.Right},
                            new Column{ItemID="Hl",Text="汇率",DataIndex="Yehl",Align=Alignment.Right},
                            new Column{ItemID="Jf",Text="借方",DataIndex="Jfje",Align=Alignment.Right},
                            new Column{ItemID="Jft",Text="借方",Columns={
                                                    new Column{ItemID="Jfsl",Text="数量",DataIndex="Jfsl",Align=Alignment.Right},
                                                    new Column{ItemID="Jfwb",Text="外币",DataIndex="Jfwb",Align=Alignment.Right},
                                                    new Column{ItemID="Jfje",Text="金额",DataIndex="Jfje",Align=Alignment.Right}
                                                 }},
                            new Column{ItemID="Df",Text="贷方",DataIndex="Dfje",Align=Alignment.Right},
                            new Column{ItemID="Dft",Text="贷方",Columns={
                                                    new Column{ItemID="Dfsl",Text="数量",DataIndex="Dfsl",Align=Alignment.Right},
                                                    new Column{ItemID="Dfwb",Text="外币",DataIndex="Dfwb",Align=Alignment.Right},
                                                    new Column{ItemID="Dfje",Text="金额",DataIndex="Dfje",Align=Alignment.Right}
                                                 }},
                            new Column{ItemID="Direction",Text="方向",DataIndex="Direction",Width=60},
                            new Column{ItemID="Ye",Text="余额",DataIndex="Yeje",Align=Alignment.Right},
                           new Column{ItemID="Yet",Text="余额",Columns={
                                                  new Column{ItemID="Yesl",Text="数量",DataIndex="Yesl",Align=Alignment.Right},
                                                    new Column{ItemID="Yewb",Text="外币",DataIndex="Yewb",Align=Alignment.Right},
                                                   new Column{ItemID="Yeje",Text="金额",DataIndex="Yeje",Align=Alignment.Right},
                                                    new Column{ItemID="Yedj",Text="单价",DataIndex="Yedj",Align=Alignment.Right},
                                                    new Column{ItemID="Yehl",Text="汇率",DataIndex="Yehl",Align=Alignment.Right}
                                                 }}
                        }
                    },
                    BottomBar = { 
                        new PagingToolbar
                        {
                            DisplayInfo=true    
                        }
                    }
                };
    
                return ComponentLoader.ToConfig(grid);
            }
    when expander it's appear title error! why?
    Last edited by Daniil; Nov 26, 2013 at 6:35 AM. Reason: [CLOSED]
  2. #2
    Hi @tobros,

    Where does the error occur? What is a JavaScript function, line of that function?
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @tobros,

    Where does the error occur? What is a JavaScript function, line of that function?
    through testing,It should be before loading data and after expander event. It's appear the google chrome console tip:"ext.axd?v=17214:18"
  4. #4
    Hello!

    Sorry, but could you set the ResourceManager's ScriptMode to Development and SourceFormatting to true:

    <ext:ResourceManager ID="ResourceManager1" runat="server" SourceFormatting="true" ScriptMode="Debug" />
    Then will be able to see readable (non-minified JS sources). Put Breakpoint to the error line and post its stacktrace and line with the name function where error occurs.
  5. #5
    hello!this is ScreenshotClick image for larger version. 

Name:	QQ图片20131119113148.jpg 
Views:	20 
Size:	46.1 KB 
ID:	7225 where is undefine?
  6. #6
    Hmm, interesting.

    Trying to reproduce it using your code snippets, I am getting:
    Not Found 
    /BBAshx/ZzmxzBB.ashx
    How does it look? Please simplify (but it must reproduce the issue anyway) before posting.
  7. #7
    Couldn't reproduce with the following sample (PlantHandler.ashx can be found in our Examples):

    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Collections.Generic"%>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (X.IsAjaxRequest)
            {
                //We do not need to DataBind on an DirectEvent
                return;
            }
            
            List<object> data = new List<object>();
            
            for (int i = 1; i <= 10; i++)
            {
                data.Add(new { ID = "S" + i, Name = "Supplier " + i});
            }
            
            this.Store1.DataSource = data;
            this.Store1.DataBind();
        }
        
        [DirectMethod]
        public static string GetGrid(Dictionary<string, string> parameters)
        {
            // string id = parameters["id"];
            
            List<object> data = new List<object>();
            
            for (int i = 1; i <= 10; i++)
            {
                data.Add(new { ID = "P" + i, Name = "Product " + i, Name2 = "Name " + i });
            }
    
            GridPanel grid = new GridPanel
            {
                Height = 200,
                EnableColumnHide = false,
                AutoScroll = true,
                StyleSpec = "border:solid 2px #3892D3",
                SortableColumns = false,
                Store = 
                { 
                    new Store 
                    { 
                        ID="store_" +  parameters["id"],
                        Model = {
                            new Model {
                                Fields = 
                                {
                                    new ModelField("Common"),
                                    new ModelField("Botanical"),
                                    new ModelField("Light")
                                }
                            }
                        },
                        Proxy={
                            new AjaxProxy(){
                                Url="../../Shared/PlantHandler.ashx",
                                Reader={
                                    new JsonReader {
                                        Root="data",
                                        TotalProperty = "total"
                                    }
                                }
                            }
                        },
                        DataSource = data
                    }
                },
                ColumnModel =
                {
                    Columns = 
                    { 
                        new Column { Text = "Common", DataIndex = "Common", Columns = { new Column { Text = "Common", DataIndex = "Common" }, new Column { Text = "Botanical", DataIndex = "Botanical" } } },
                        new Column { Text = "Light", DataIndex = "Light", Columns = { new Column { Text = "Light", DataIndex = "Light" }, new Column { Text = "Botanical", DataIndex = "Botanical" } } }
                    }
                },
                BottomBar = 
                {
                    new PagingToolbar
                    {
                        DisplayInfo=true   
                    }
                }
            };
    
            return ComponentLoader.ToConfig(grid);
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:GridPanel 
                runat="server"             
                Title="Expander Rows with GridPanel"
                Collapsible="true"
                AnimCollapse="true" 
                Icon="Table" 
                Width="600"
                Height="450"
                DisableSelection="true">
                <Store>
                    <ext:Store ID="Store1" runat="server">
                        <Model>
                            <ext:Model runat="server" IDProperty="ID">
                                <Fields>
                                    <ext:ModelField Name="ID" />
                                    <ext:ModelField Name="Name" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">               
                    <Columns>       
                        <ext:Column runat="server" Text="Supplier" DataIndex="Name" Flex="1" />
                    </Columns>
                </ColumnModel>            
                <Plugins>
                    <ext:RowExpander runat="server" ExpandOnDblClick="true" ExpandOnEnter="true" IsDynamic="true" SingleExpand="true" ScrollOffset="10">
                        <Loader runat="server" DirectMethod="#{DirectMethods}.GetGrid" Mode="Component">
                            <LoadMask ShowMask="true" />
                            <Params>
                                <ext:Parameter Name="id" Value="this.record.getId()" Mode="Raw" />
                            </Params>
                        </Loader>
                    </ext:RowExpander>
                </Plugins>            
            </ext:GridPanel>
        </form>
    </body>
    </html>
  8. #8
    Quote Originally Posted by Daniil View Post
    Hmm, interesting.

    Trying to reproduce it using your code snippets, I am getting:
    Not Found 
    /BBAshx/ZzmxzBB.ashx
    How does it look? Please simplify (but it must reproduce the issue anyway) before posting.

    The json data returned is definitely correct!!because the grid data can corrent appear. The key is in localhost is corrent.but After the release of the data dose not appear!
  9. #9
    Quote Originally Posted by Baidaly View Post
    Couldn't reproduce with the following sample (PlantHandler.ashx can be found in our Examples):

    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Collections.Generic"%>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (X.IsAjaxRequest)
            {
                //We do not need to DataBind on an DirectEvent
                return;
            }
            
            List<object> data = new List<object>();
            
            for (int i = 1; i <= 10; i++)
            {
                data.Add(new { ID = "S" + i, Name = "Supplier " + i});
            }
            
            this.Store1.DataSource = data;
            this.Store1.DataBind();
        }
        
        [DirectMethod]
        public static string GetGrid(Dictionary<string, string> parameters)
        {
            // string id = parameters["id"];
            
            List<object> data = new List<object>();
            
            for (int i = 1; i <= 10; i++)
            {
                data.Add(new { ID = "P" + i, Name = "Product " + i, Name2 = "Name " + i });
            }
    
            GridPanel grid = new GridPanel
            {
                Height = 200,
                EnableColumnHide = false,
                AutoScroll = true,
                StyleSpec = "border:solid 2px #3892D3",
                SortableColumns = false,
                Store = 
                { 
                    new Store 
                    { 
                        ID="store_" +  parameters["id"],
                        Model = {
                            new Model {
                                Fields = 
                                {
                                    new ModelField("Common"),
                                    new ModelField("Botanical"),
                                    new ModelField("Light")
                                }
                            }
                        },
                        Proxy={
                            new AjaxProxy(){
                                Url="../../Shared/PlantHandler.ashx",
                                Reader={
                                    new JsonReader {
                                        Root="data",
                                        TotalProperty = "total"
                                    }
                                }
                            }
                        },
                        DataSource = data
                    }
                },
                ColumnModel =
                {
                    Columns = 
                    { 
                        new Column { Text = "Common", DataIndex = "Common", Columns = { new Column { Text = "Common", DataIndex = "Common" }, new Column { Text = "Botanical", DataIndex = "Botanical" } } },
                        new Column { Text = "Light", DataIndex = "Light", Columns = { new Column { Text = "Light", DataIndex = "Light" }, new Column { Text = "Botanical", DataIndex = "Botanical" } } }
                    }
                },
                BottomBar = 
                {
                    new PagingToolbar
                    {
                        DisplayInfo=true   
                    }
                }
            };
    
            return ComponentLoader.ToConfig(grid);
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:GridPanel 
                runat="server"             
                Title="Expander Rows with GridPanel"
                Collapsible="true"
                AnimCollapse="true" 
                Icon="Table" 
                Width="600"
                Height="450"
                DisableSelection="true">
                <Store>
                    <ext:Store ID="Store1" runat="server">
                        <Model>
                            <ext:Model runat="server" IDProperty="ID">
                                <Fields>
                                    <ext:ModelField Name="ID" />
                                    <ext:ModelField Name="Name" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">               
                    <Columns>       
                        <ext:Column runat="server" Text="Supplier" DataIndex="Name" Flex="1" />
                    </Columns>
                </ColumnModel>            
                <Plugins>
                    <ext:RowExpander runat="server" ExpandOnDblClick="true" ExpandOnEnter="true" IsDynamic="true" SingleExpand="true" ScrollOffset="10">
                        <Loader runat="server" DirectMethod="#{DirectMethods}.GetGrid" Mode="Component">
                            <LoadMask ShowMask="true" />
                            <Params>
                                <ext:Parameter Name="id" Value="this.record.getId()" Mode="Raw" />
                            </Params>
                        </Loader>
                    </ext:RowExpander>
                </Plugins>            
            </ext:GridPanel>
        </form>
    </body>
    </html>

    Proxy={
                            new AjaxProxy(){
                                Url="../../Shared/PlantHandler.ashx",
                                Reader={
                                    new JsonReader {
                                        Root="data",
                                        TotalProperty = "total"
                                    }
                                }
                            }
                        },
                        DataSource = data
    Why use two data sources?
  10. #10
    In fact, in my program. The "ColumnModel" is dynamic.
            public void SetGridPanelByGridType(ref GridPanel gridpanel, GridType gridType)
            {
                if (gridpanel == null)
                {
                    throw new ArgumentNullException("gridpanel", "gridpanel 为空");
                }
                gridpanel.SelectionModel.Clear();
                gridpanel.ColumnModel.Columns.Clear();
    
                //store.Proxy.Add(SetStoreProxy(gridType, url));
                gridpanel.SelectionModel.Add(new RowSelectionModel { Mode = SelectionMode.Single });
                gridpanel.ColumnModel.Columns.Add(GetColumnsByGridType(gridType));
            }
    The GetColumnsByGridType method is dynamic return need display column.
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: Nov 14, 2013, 9:44 PM
  2. Replies: 5
    Last Post: Oct 30, 2013, 1:29 PM
  3. Uncaught TypeError: Cannot read property 'items' of null
    By FlavioSilveira in forum 2.x Help
    Replies: 6
    Last Post: Sep 20, 2013, 7:37 PM
  4. Replies: 1
    Last Post: Jun 05, 2013, 11:01 AM
  5. Replies: 4
    Last Post: May 30, 2013, 1:36 PM

Posting Permissions