PDA

View Full Version : [CLOSED] Loading a FormPanel that contains a SelectBox



RCN
May 14, 2012, 6:03 PM
Hi folks, i have an automatization that generates the interface and flush it for rendering. But when i try to flush a FormPanel that contains a SelectBox, the ExtJs throws an exception when it tries to rewrite namespaces (Ext.ClassManager.parseNamespace - http://docs.sencha.com/ext-js/4-0/source/ClassManager.html#Ext-ClassManager) .

1 - Panel where FormPanel is gonna be rendered


<ext:Viewport ID="Viewport1" Layout="BorderLayout" Border="false" runat="server">
<Items>
<ext:Panel ID="Panel1" Region="Center" runat="server" Title="PNL">
<Loader ID="Loader1" runat="server" AutoLoad="true" Mode="Component" Url="/Example/TestSelectBox/">
<LoadMask ShowMask="true" />
</Loader>
</ext:Panel>
</Items>
</ext:Viewport>


2 - Result of interface generation


public ActionResult TestSelectBox()
{
string str = "{bin:[Ext.create(\"Ext.data.Store\",{model:Ext.define(Ext.id(), {extend: \"Ext.data.Model\", fields:[{name:\"ID\",mapping:\"ID\"},{name:\"TipoDeRegistro\",mapping:\"TipoDeRegistro\"}] }),storeId:\"_elpFormularioDeAtualizacao_store\",proxy:{data:[],type:'memory'}})],id:\"_elpFormularioDeAtualizacao\",xtype:\"form\",defaults:{\"msgTarget\":\"side\"},items:[{xtype:\"textfield\",anchor:\"100%\",fieldLabel:\"ID\",name:\"ID\",readOnly:true},{xtype:\"selectbox\",anchor:\"100%\",fieldLabel:\"TipoDeRegistro\",name:\"TipoDeRegistro\",allowBlank:false,queryMode:\"local\",triggerAction:\"all\"}]}";
return new ContentResult { Content = str };
}

3 - A better view of generated code


{
bin: [Ext.create("Ext.data.Store", {
model: Ext.define(Ext.id(), {
extend: "Ext.data.Model",
fields: [{
name: "ID",
mapping: "ID"
}, {
name: "TipoDeRegistro",
mapping: "TipoDeRegistro"
}]
}),
storeId: "_elpFormularioDeAtualizacao_store",
proxy: {
data: [],
type: 'memory'
}
})],
id: "_elpFormularioDeAtualizacao",
xtype: "form",
defaults: {
"msgTarget": "side"
},
items: [{
xtype: "textfield",
anchor: "100%",
fieldLabel: "ID",
name: "ID",
readOnly: true
}, {
xtype: "selectbox",
anchor: "100%",
fieldLabel: "TipoDeRegistro",
name: "TipoDeRegistro",
allowBlank: false,
queryMode: "local",
triggerAction: "all",
store: [
["Visao", "Visao"],
["Menu", "Menu"],
["Acesso", "Acesso"],
["Pagina", "Pagina"]
]
}]
}

The code above throws the exception mentioned on the beginning of this post.

The following code works because the FormPanel does not have a SelectBox inside.


public ActionResult TestSelectBox()
{
string str = "{bin:[Ext.create(\"Ext.data.Store\",{model:Ext.define(Ext.id(), {extend: \"Ext.data.Model\", fields:[{name:\"ID\",mapping:\"ID\"},{name:\"TipoDeRegistro\",mapping:\"TipoDeRegistro\"}] }),storeId:\"_elpFormularioDeAtualizacao_store\",proxy:{data:[],type:'memory'}})],id:\"_elpFormularioDeAtualizacao\",xtype:\"form\",defaults:{\"msgTarget\":\"side\"},items:[{xtype:\"textfield\",anchor:\"100%\",fieldLabel:\"ID\",name:\"ID\",readOnly:true}]}";
return new ContentResult { Content = str };
}




{
bin: [Ext.create("Ext.data.Store", {
model: Ext.define(Ext.id(), {
extend: "Ext.data.Model",
fields: [{
name: "ID",
mapping: "ID"
}, {
name: "TipoDeRegistro",
mapping: "TipoDeRegistro"
}]
}),
storeId: "_elpFormularioDeAtualizacao_store",
proxy: {
data: [],
type: 'memory'
}
})],
id: "_elpFormularioDeAtualizacao",
xtype: "form",
defaults: {
"msgTarget": "side"
},
items: [{
xtype: "textfield",
anchor: "100%",
fieldLabel: "ID",
name: "ID",
readOnly: true
}]
}


Any idea to overcome this problem?

Daniil
May 14, 2012, 9:04 PM
Hi,

Confirmed, thanks for the report.

I have reproduced the problem with the example below. We will investigate.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
[DirectMethod]
public static string GetFormPanel()
{
return ComponentLoader.ToConfig(new FormPanel()
{
Items =
{
new SelectBox()
{
Items =
{
new Ext.Net.ListItem("Item 1"),
new Ext.Net.ListItem("Item 2")
}
}
}
});
}
</script>

<!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 runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />

<ext:Container
runat="server"
Height="100">
<Loader
runat="server"
AutoLoad="true"
Mode="Component"
DirectMethod="#{DirectMethods}.GetFormPanel">
</Loader>
</ext:Container>
</body>
</html>

Daniil
May 14, 2012, 9:10 PM
I forgot that SelectBox is an UX. In the case with ComponentLoader the SelectBox resources must be registered manually.

protected void Page_Load(object sender, EventArgs e)
{
ResourceManager.RegisterControlResources<SelectBox>();
}

RCN
May 15, 2012, 11:34 AM
I forgot that SelectBox is an UX. In the case with ComponentLoader the SelectBox resources must be registered manually.

protected void Page_Load(object sender, EventArgs e)
{
ResourceManager.RegisterControlResources<SelectBox>();
}
The code above works for non-mvc apllications, but im working with mvc.

is there a way to register the control resources when flushing the interface for rendering?

Daniil
May 15, 2012, 11:36 AM
It works well for an MVC application, I've tested. I don't think it's a problem to register these resources within View Page_Load.

RCN
May 15, 2012, 11:54 AM
thank you Daniil, please mark it as resolved