[CLOSED] Loading a FormPanel that contains a SelectBox

  1. #1

    [CLOSED] Loading a FormPanel that contains a SelectBox

    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/so...t-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?
    Last edited by Daniil; May 15, 2012 at 11:56 AM. Reason: [CLOSED]
  2. #2
    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>
  3. #3
    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>();
    }
  4. #4
    Quote Originally Posted by Daniil View Post
    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 i´m working with mvc.

    is there a way to register the control resources when flushing the interface for rendering?
  5. #5
    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.
  6. #6
    thank you Daniil, please mark it as resolved

Similar Threads

  1. Replies: 1
    Last Post: Sep 13, 2012, 7:52 AM
  2. [CLOSED] Loading Partial View under a formpanel
    By Daly_AF in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 25, 2012, 2:26 PM
  3. Replies: 4
    Last Post: Oct 24, 2011, 3:34 AM
  4. trouble loading formpanel from gridpanel
    By cPrinciple in forum 1.x Help
    Replies: 0
    Last Post: Aug 02, 2011, 6:15 AM
  5. Replies: 4
    Last Post: May 31, 2011, 3:53 PM

Posting Permissions