[CLOSED] Combobox inside Menu

  1. #1

    [CLOSED] Combobox inside Menu

    Hello,

    I have a button, when I click it, it opens a menu which contains a combobox. What I'm trying to do is getting the combobox value when I change its value, but it always returns null.

    I have created a demo:

    Here is my Carrito_repre2.aspx file:
    <%@ Page Title="Extranet Jhayber" Language="C#" 
        CodeBehind="Carrito_repre2.aspx.cs" Inherits="Extranet.Carrito_repre2" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Import Namespace="System.Xml" %>
    
    <html>
    <head runat="server">
    </head>
    <body>
    <form runat="server">
    
        <ext:ResourceManager runat="server" />
        <ext:Button ID="Button1"
            MarginSpec = "0 0 0 500"
            MinWidth="10"
            runat="server"
            MenuAlign="tr-br"
            Text="menu">
            <Menu>
                    <ext:Menu runat="server" ID="menucliente">
                        <Items>
                            <ext:Panel runat="server" Width="400" Height="100">
                                <Items>
                                    <ext:ComboBox ID="ComboClientes1" runat="server"  TypeAhead="true" EnableRegEx="true" MarginSpec="10 10 0 20"
                                        Mode="Local" EmptyText="Selecciona un valor..." LabelWidth="60" LabelAlign="Left" SelectOnFocus="true" FieldLabel="combo1:" DisplayField="Name"
                                        ValueField="Name" HiddenName="Name" ColumnWidth="0.9" Frame="true" AutoSelect="true" AutoShow="true"  padding="5" Width="355">
                                        <Store>
                                            <ext:Store ID="Store1" runat="server">
                                                    <Model>
                                                        <ext:Model ID="Model1" runat="server">
                                                            <Fields>
                                                                <ext:ModelField Name="Name" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>                
                                            </ext:Store>
                                        </Store>
                                        <DirectEvents>
                                            <Change OnEvent="getcombo"></Change>
                                        </DirectEvents>
                                    </ext:ComboBox>
                                </Items>
                            </ext:Panel>
                        </Items>
                    </ext:Menu>
                </Menu>
            </ext:Button>
    
    
    </form>
    </body>
    </html>
    And here is my Carrito_repre2.aspx.cs file:

    using System;
    using System.Collections.Generic;
    using Ext.Net;
    
    namespace Extranet
    {
        public partial class Carrito_repre2 : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                Store1.DataSource = values;
                Store1.DataBind();
            }
    
            public List<object> values
            {
                get
                {
                    return new List<object>
                    {
                        new { Name = "1" },
                        new { Name = "2" },
                        new { Name = "3" },
                        new { Name = "4" },
                        new { Name = "5 "}
                    };
                }
            }
    
            public void getcombo (object sender, DirectEventArgs e)
            {
                string combovalue = ComboClientes1.SelectedItem.Value;
            }
        }  
    }
    I want to get the combo value, but in line 32 combovalue is always null.

    I forgot to mention that I have tried to do the same without placing the combobox inside a menu and it worked perfect.
    Last edited by fabricio.murta; Dec 01, 2017 at 6:04 PM.
  2. #2
    Hello @PascuV! And welcome to Ext.NET forums!

    Menus' dynamic positioning and displaying nature forces them to be drawn somewhere in the DOM that's not bound to any component. So what you're getting is that the combo box -- which is contained within the menus DOM elements -- ends up being "physically" drawn outside the page's <form /> block.

    To address this issue whenever you have components within menus, that should submit, you can just set RenderToForm="true" in the menu definition.

    Alternatively, in some circumstances where you may not want the component to be actually a part of the page's main form, you can excplicitly specify what you want to submit with the direct event, like explained here: ComboBox.SelectedItem.Value is null in DirectEvents Select.

    I hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    It Works! Thank You very much
  4. #4
    Glad it helped, thanks for the feedback!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] combobox inside a menu and directevent
    By mirwais in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 12, 2013, 7:43 AM
  2. Insert a Menu inside a Menu
    By martinr84 in forum 1.x Help
    Replies: 0
    Last Post: Jul 16, 2012, 8:27 PM
  3. Replies: 2
    Last Post: Sep 21, 2010, 11:14 AM
  4. [CLOSED] Menu inside Component menu item
    By tansu in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 15, 2010, 2:32 PM
  5. launch new page from menu inside a tab
    By manelj in forum 1.x Help
    Replies: 0
    Last Post: Oct 12, 2008, 2:31 PM

Posting Permissions