Javascript EXT-NET:未捕获类型错误:无法读取属性';类型';空的
我正在尝试实现此示例: 但当我单击展开外部网格时,我收到以下错误: 未捕获的TypeError:无法读取null的属性“type”Javascript EXT-NET:未捕获类型错误:无法读取属性';类型';空的,javascript,c#,extjs,grid,ext.net,Javascript,C#,Extjs,Grid,Ext.net,我正在尝试实现此示例: 但当我单击展开外部网格时,我收到以下错误: 未捕获的TypeError:无法读取null的属性“type” at F.setLayout (ext.axd:19) at F.getLayout (ext.axd:19) at F.add (ext.axd:19) at g.Ext.ComponentLoader.Renderer.Component (ext.axd:445) at g.onComplete (ext.axd:495) at Object.complet
at F.setLayout (ext.axd:19)
at F.getLayout (ext.axd:19)
at F.add (ext.axd:19)
at g.Ext.ComponentLoader.Renderer.Component (ext.axd:445)
at g.onComplete (ext.axd:495)
at Object.complete (ext.axd:463)
at Object.userSuccess (ext.axd:268)
at F.executeScriptDelay (ext.axd:256)
at F.executeScript (ext.axd:255)
at F.requestSuccessHandler (ext.axd:248)
通过使用断点,我发现错误发生在从DirectMethod返回后。我没有发布外部网格(misArtStore
)的代码,因为它工作正常
这是我的密码:
标记
<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="misArtStore" runat="server">
<Model>
<ext:Model runat="server" IDProperty="Id">
<Fields>
<ext:ModelField Name="Id" />
<ext:ModelField Name="missing" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Artifacts" DataIndex="missing" Flex="1" Hideable="false" />
</Columns>
</ColumnModel>
<Plugins>
<ext:RowExpander runat="server">
<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>
编辑
(使用@Przemek提供的解决方案解决图像中的错误)这是linq查询的问题,而不是网格。尝试使用:
DataSource = sites.ToList()
或创建自己的自定义对象列表:
public class CustomObject
{
public string Siteid {get; set; }
public string Site {get; set; }
}
(...)
select new CustomObject() { Siteid = st.Siteid, Site = st.FullName });
编辑
无数据库连接的工作示例:
*.aspx:
<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="misArtStore" runat="server">
<Model>
<ext:Model runat="server" IDProperty="Id">
<Fields>
<ext:ModelField Name="Id" />
<ext:ModelField Name="missing" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Artifacts" DataIndex="missing"
Flex="1" Hideable="false" />
</Columns>
</ColumnModel>
<Plugins>
<ext:RowExpander runat="server">
<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>
*.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack || X.IsAjaxRequest)
return;
misArtStore.DataSource = new object[]
{
new { Id = "1", missing = "missing 1" },
new { Id = "2", missing = "missing 2" },
new { Id = "3", missing = "missing 3" }
};
misArtStore.DataBind();
}
[DirectMethod]
public string GetGrid(Dictionary<string, string> parameters)
{
GridPanel grid = new GridPanel
{
Height = 200,
EnableColumnHide = false,
Store =
{
new Store
{
Model =
{
new Model
{
IDProperty = "Siteid",
Fields = { new ModelField("Siteid"), new ModelField("Site") }
}
},
DataSource = new object[]
{
new { Siteid = "1", Site = "Site 1" },
new { Siteid = "2", Site = "Site 2" }
}
}
},
ColumnModel =
{
Columns = { new Column { Text = "Site", DataIndex = "Site", Width = 150 } }
}
};
return ComponentLoader.ToConfig(grid);
}
受保护的无效页面加载(对象发送方,事件参数e)
{
if(Page.IsPostBack | | X.isajax请求)
返回;
misArtStore.DataSource=新对象[]
{
新的{Id=“1”,missing=“missing 1”},
新的{Id=“2”,missing=“missing 2”},
新的{Id=“3”,missing=“missing 3”}
};
misArtStore.DataBind();
}
[直接法]
公共字符串GetGrid(字典参数)
{
GridPanel grid=新的GridPanel
{
高度=200,
EnableColumnHide=false,
贮藏=
{
新店
{
型号=
{
新型
{
IDProperty=“Siteid”,
字段={new ModelField(“Siteid”),new ModelField(“Site”)}
}
},
数据源=新对象[]
{
新建{Siteid=“1”,Site=“Site 1”},
新建{Siteid=“2”,Site=“Site 2”}
}
}
},
柱状模型=
{
Columns={newcolumn{Text=“Site”,DataIndex=“Site”,Width=150}
}
};
返回ComponentLoader.ToConfig(网格);
}
这是linq查询的问题,而不是网格。尝试使用:
DataSource = sites.ToList()
或创建自己的自定义对象列表:
public class CustomObject
{
public string Siteid {get; set; }
public string Site {get; set; }
}
(...)
select new CustomObject() { Siteid = st.Siteid, Site = st.FullName });
编辑
无数据库连接的工作示例:
*.aspx:
<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="misArtStore" runat="server">
<Model>
<ext:Model runat="server" IDProperty="Id">
<Fields>
<ext:ModelField Name="Id" />
<ext:ModelField Name="missing" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Artifacts" DataIndex="missing"
Flex="1" Hideable="false" />
</Columns>
</ColumnModel>
<Plugins>
<ext:RowExpander runat="server">
<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>
*.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack || X.IsAjaxRequest)
return;
misArtStore.DataSource = new object[]
{
new { Id = "1", missing = "missing 1" },
new { Id = "2", missing = "missing 2" },
new { Id = "3", missing = "missing 3" }
};
misArtStore.DataBind();
}
[DirectMethod]
public string GetGrid(Dictionary<string, string> parameters)
{
GridPanel grid = new GridPanel
{
Height = 200,
EnableColumnHide = false,
Store =
{
new Store
{
Model =
{
new Model
{
IDProperty = "Siteid",
Fields = { new ModelField("Siteid"), new ModelField("Site") }
}
},
DataSource = new object[]
{
new { Siteid = "1", Site = "Site 1" },
new { Siteid = "2", Site = "Site 2" }
}
}
},
ColumnModel =
{
Columns = { new Column { Text = "Site", DataIndex = "Site", Width = 150 } }
}
};
return ComponentLoader.ToConfig(grid);
}
受保护的无效页面加载(对象发送方,事件参数e)
{
if(Page.IsPostBack | | X.isajax请求)
返回;
misArtStore.DataSource=新对象[]
{
新的{Id=“1”,missing=“missing 1”},
新的{Id=“2”,missing=“missing 2”},
新的{Id=“3”,missing=“missing 3”}
};
misArtStore.DataBind();
}
[直接法]
公共字符串GetGrid(字典参数)
{
GridPanel grid=新的GridPanel
{
高度=200,
EnableColumnHide=false,
贮藏=
{
新店
{
型号=
{
新型
{
IDProperty=“Siteid”,
字段={new ModelField(“Siteid”),new ModelField(“Site”)}
}
},
数据源=新对象[]
{
新建{Siteid=“1”,Site=“Site 1”},
新建{Siteid=“2”,Site=“Site 2”}
}
}
},
柱状模型=
{
Columns={newcolumn{Text=“Site”,DataIndex=“Site”,Width=150}
}
};
返回ComponentLoader.ToConfig(网格);
}
谢谢!我解决了图像中的错误,但仍然收到javascript错误uncaughttypeerror:cannotreadproperty'type'of null
我相信这property'type'of null
与网格问题无关。我在第一个答案中添加了工作解决方案。但为什么在我尝试扩展行扩展器时会显示工作解决方案呢?我尝试了你的解决方案,但还是犯了同样的错误。所以它可能和数据源无关
我的解决方案在我的环境中的控制台中运行时没有任何错误。我可以建议在没有任何外部框架的情况下创建一个全新的项目,除了ext.net,然后尝试一下。。。我也在这里工作。但是为什么不在我的项目中工作呢?谢谢!我解决了图像中的错误,但仍然收到javascript错误uncaughttypeerror:cannotreadproperty'type'of null
我相信这property'type'of null
与网格问题无关。我在第一个答案中添加了工作解决方案。但为什么在我尝试扩展行扩展器时会显示工作解决方案呢?我尝试了你的解决方案,但还是犯了同样的错误。所以它可能和数据源无关
我的解决方案在我的环境中的控制台中运行时没有任何错误。我可以建议在没有任何外部框架的情况下创建一个全新的项目,除了ext.net,然后尝试一下。。。我也在这里工作。但为什么不在我的项目中工作呢?