[CLOSED] Combo initialization with no selection on window show.

  1. #1

    [CLOSED] Combo initialization with no selection on window show.

    Hi

    I am using an embedded <ext:Window> with a combo control to add an item to the opener page.
    Each time that window shows I set the datasource to the combo with fresh data, but want the combo to show no selection.

    The first time the window opens, the combo shows the "EmptyText" ('Seleccionar', that means 'Select' in Spanish).

    Once the window is closed and shown again, the combo receives the new fresh datasource (Set every time a DirectEvent shows the popup window), but the combo remembers its last selection.

    I want it always to show the EmptyText.

    I tried setting selectedInedex = -1, but doesn't work. I can set selectedIndex = 0, and there the first item is shown always, but I don't want that. Also I belive that if no items are added by datasource, that index will produce an error.

    Tried using closeAction='close', but I believe the window can't be rendered again calling the show() method a second time (I saw that in a post).

    Just for your reference, 'Idioma' means 'language', 'Mostrar' means 'Show', 'Ventana' means 'Window' and 'Agregar' means 'Add' in Spanish

    The opening code:
    <ext:Button runat="server" ID="btnAgregarIdioma" Text="+" Width="20">
                                        <DirectEvents>
                                            <Click OnEvent="MostrarVentanaIdiomas"></Click>
                                        </DirectEvents>
                                     </ext:Button>
    The serverside DirectEvent:
    Protected Sub MostrarVentanaIdiomas()
    
    
            'HERE, NOT RELEVANT CODE TO OBTAIN DATATABLE FOR DATASOURCE
    
    
            Me.IdiomasAgregarStore.DataSource = mDs.Tables(0)
            Me.IdiomasAgregarStore.DataBind()
    
    
            Me.VentanaIdiomas.Show()
    
    
            Me.cmbIdiomasAgregar.SelectedIndex = -1 'HERE IT IS SUPOSED I FORCE THE COMBO TO SHOW THE EMPTY TEXT
    
    
            VentanaIdiomas.Center()
        End Sub
    The popup window:

    <ext:Window 
                                        ID="VentanaIdiomas" 
                                        runat="server" 
                                        Icon="WorldAdd"
                                        Title="Agregar traducción" 
                                        Hidden="true" 
                                         Modal="true"
                                          InitCenter="true"
                                           Width="300px"
                                        Height="80px"
                                         Padding="0"
                                        >
                                        
                                        <Items>
                                        
                                        <ext:FormPanel runat="server" Padding="5" AutoHeight="true" ButtonAlign="Right" >
                                        
                                        <Items>
                                        
                                        <ext:ComboBox runat="server" ID="cmbIdiomasAgregar" 
                                        FieldLabel="Idioma"
                                         StoreID="IdiomasAgregarStore"
                                         DisplayField="Idioma_Nombre"
                                         ValueField="Idioma_Id"
                                          AllowBlank="false"
                                           EmptyText="Seleccionar"
                                            InvalidText="Debe seleccionar un idioma para agregar"
                                             ForceSelection="true"
                                              Editable="false"
                                               TypeAhead="false">
                                         
                                        </ext:ComboBox>
                                       
                                        
                                        </Items>
                                        <Buttons>
                                         <ext:Button runat="server" ID="btnAgregar" Text="Agregar" Margins="0">
                                        
                                        </ext:Button>
                                        <ext:Button runat="server" ID="btnCancelarIdiomas" Text="Cancelar" Margins="0">
                                        </ext:Button>
                                        </Buttons>
                                        </ext:FormPanel>
                                        </Items>
                                        </ext:Window>
    Thanks
    Regards
    Fernando
    Last edited by geoffrey.mcgill; Feb 22, 2012 at 5:37 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Pleas call the ComboBox Clear method.
    ComboBox1.Clear()
  3. #3
    Thanks.
    Things solved.

    Just for anyone looking to this thread, after the Clear() I have to call ClearInvalid() method to avoid having always invalid empty selection warning on window load.

    Regards
    Fernando

Similar Threads

  1. Replies: 3
    Last Post: Mar 19, 2012, 12:35 PM
  2. Replies: 6
    Last Post: Aug 25, 2011, 2:13 PM
  3. [CLOSED] Combo Box Pre-Selection Problem
    By IanPearce in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Jun 07, 2011, 3:43 PM
  4. [CLOSED] combo boxes initialization
    By alexp in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 04, 2010, 11:11 AM
  5. Combo Force Selection
    By simonmicheal in forum 1.x Help
    Replies: 3
    Last Post: Aug 15, 2009, 2:30 PM

Tags for this Thread

Posting Permissions