PDA

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



tobros
Nov 18, 2013, 8:31 AM
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.getSelectionMode l().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?

Daniil
Nov 18, 2013, 12:20 PM
Hi @tobros,

Where does the error occur? What is a JavaScript function, line of that function?

tobros
Nov 19, 2013, 2:21 AM
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"

Baidaly
Nov 19, 2013, 3:15 AM
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.

tobros
Nov 19, 2013, 3:33 AM
hello!this is Screenshot7225 where is undefine?

Daniil
Nov 19, 2013, 3:56 AM
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.

Baidaly
Nov 19, 2013, 4:12 AM
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>

tobros
Nov 20, 2013, 7:51 AM
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!

tobros
Nov 20, 2013, 7:54 AM
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?

tobros
Nov 20, 2013, 7:57 AM
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(GetColumnsByGrid Type(gridType));
}

The GetColumnsByGridType method is dynamic return need display column.

Daniil
Nov 20, 2013, 12:45 PM
Proxy={
new AjaxProxy(){
Url="../../Shared/PlantHandler.ashx",
Reader={
new JsonReader {
Root="data",
TotalProperty = "total"
}
}
}
},
DataSource = data

Why use two data sources?

Probably, by mistake.


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!

It would be a big help for us if you can provide a test case to reproduce.