[CLOSED] combobox setValue does not work

  1. #1

    [CLOSED] combobox setValue does not work

    Hello there. When using the SetValue method of combobox server side I can not get the combobox to display selected value text.
    I also tried calling the setValue of combobox client side using addScript.
    Neither one worked.
    Any hint?

    Here goes example code:

    <%@ Page Language="VB"  %>
    <%@  Import Namespace="Ext.Net" %>
    <%@  Import Namespace="Psa.data" %>
    <%@  Import Namespace="Psa.Convert" %>
    <%@  Import Namespace="Psa.Session" %>
    <%@  Import Namespace="System.Data" %>
    
    <!DOCTYPE html>
    
    <script runat="server">
    
        Protected Overloads Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not Ext.Net.X.IsAjaxRequest Then
                BindData()
            End If
    
        End Sub
    
        Private Sub BindData()
            Dim sql As String 
            sql = "select cmpy_code,name_text + ' -> ' + cmpy_code name_text from company a"
            Dim conn = PsaData.CreateConnection(PsaSession.ConnectionString)
            Dim dv As System.Data.DataView = PsaData.CreateDataView(sql, conn)
            conn = Nothing
            Store1.DataSource = dv
            Store1.DataBind()
            cmpy_code.SetRawValue(PsaSession.Cmpy)
            Dim scr As String = cmpy_code.ClientID & ".setValue('98');"
            'cmpy_code.AddScript(scr)
        End Sub
        
        
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
         <extnet:ResourceManager ID="ResourceManager1" runat="server" Theme="Gray">
        </extnet:ResourceManager>
    
            <extnet:Store ID="Store1" runat="server">
            <Model>
                <extnet:Model ID="Model2" runat="server">
                    <Fields>
                        <extnet:ModelField Name="cmpy_code" Type="String" />
                        <extnet:ModelField Name="name_text" Type="String" />
                    </Fields>
                </extnet:Model>
            </Model>
        </extnet:Store>
        <extnet:Viewport ID='Viewport1' runat='server' Layout='BorderLayout'>
            <Items>
                <extnet:Panel ID="Panel1" runat="server" Flex="1" Layout="AnchorLayout" BodyPadding="5"
                    Region="Center"
                    DefaultAnchor="100%" Border="true" Title="Cambiar de Empresa">
                    <Items>
                        <extnet:ComboBox runat="server"
                            ID="cmpy_code"
                            TypeAhead="true"
                            QueryMode="local"
                            ForceSelection="true"
                            Editable="false"
                            MultiSelect="false"
                            EmptyText="Seleccione un valor de la lista..."
                            AllowBlank="False"
                            FieldLabel="Empresa"
                            StoreId="Store1"
                            ValueField="cmpy_code" DisplayField="name_text">
                        </extnet:ComboBox>
                    </Items>
               </extnet:Panel>
            </Items>
        </extnet:Viewport>
        </form>
    </body>
    </html>
    Last edited by Daniil; Apr 01, 2014 at 2:34 AM. Reason: [CLOSED]
  2. #2
    Try this..

    cmpy_code.SelectedItems.Add(new Ext.Net.ListItem { Value = '98', Mode = ParameterMode.Raw })
    Edit -- you use VB.NET, so you probably need to alter a little bit :) ..
    Last edited by CarWise; Mar 31, 2014 at 11:12 AM.
  3. #3
    O, I tried it, did not worked.
    Still selected item not showed in combobox.

    I have also tried filling items manually with .items.add(new ext.net.listitem with) and it does nor work either.
    Already updated version to 2.5.

    Any other hint?
  4. #4
    I have made and additional test adding a button and wiring a direct click event in which have called the setValue method and worked Ok.
    I guess something is not already setup on page_load than is preventing for the method to work fine.
  5. #5
    ok, according to other thread I found, during page_load stage one should use selectedItem.value = value to assign selected value to combobox. I tried in my example and worked fine. Believe you can close the case now.

Similar Threads

  1. [CLOSED] NumberField setRawValue can still fire changed event
    By glenh in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 02, 2014, 1:08 AM
  2. [CLOSED] combobox setrowvalue code behind does not work
    By jstifel in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Jan 07, 2014, 4:32 AM
  3. Replies: 0
    Last Post: Jul 19, 2012, 7:09 AM
  4. [CLOSED] Linked Combobox can't work
    By gs_user in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: May 02, 2012, 7:26 AM
  5. ComboBox won't work with .net 2.0
    By msnyder0 in forum 1.x Help
    Replies: 1
    Last Post: Nov 06, 2008, 2:29 PM

Tags for this Thread

Posting Permissions