[CLOSED] Get ComboBox Selected Value as ExtraParams

  1. #1

    [CLOSED] Get ComboBox Selected Value as ExtraParams


    I'm passing ExtraParams on Button Click DirectEvents as following:

    <ext:Button ID="btnSaveReceiptInfo" ClientIDMode="Static" runat="server" Icon="DiskBlack" Text="Save"  >
    	<Click OnEvent="AddNewReceipt" Before="if(validateReceiptInput()) { return true; }else{ return false; }">
    				Encode="false" />
    And Payment Currency List is defined as following:

    <ext:ComboBox ID="ddlPaymentCurrency" LabelWidth="180" AllowBlank="false" ClientIDMode="Static" Flex="1" ValueField="CURRENCYID" DisplayField="CURRENCY_NAME_E" runat="server"  LabelAlign="Left" FieldLabel="Currency">
    		<ext:Store ID="ddlPaymentCurrencyStore" runat="server">
    				<ext:Model ID="ddlPaymentCurrencyModel" runat="server" >
    						<ext:ModelField Name="CURRENCYID"  />
    						<ext:ModelField Name="CURRENCY_NAME_E"   Type="String" />
    						<ext:ModelField Name="EXCHANGE_RATE"   />
    When executing the event code:

    <DirectMethod(ShowMask:=True, Msg:="Adding Receipt...")> _
        Function AddNewReceipt(sender As Object, e As DirectEventArgs) As Boolean
            Dim PaymentCurrency As String = e.ExtraParams("myPaymentCurrency")
            Return True
        End Function
    The value submitted is the DisplayField="CURRENCY_NAME_E" but what I want is ValueField="CURRENCYID".

    How to achieve that?

    Last edited by fabricio.murta; Mar 22, 2016 at 11:23 PM. Reason: no user feedback for 7+ days
  2. #2
    Hello Alaswad!

    I'm not sure whats happening there... I get the expected field when I run this example:

    <%@ Page Language="C#" %>
    <!DOCTYPE html>
    <script runat="server">
        private object TestData
                return new object[]
                    new object[] { "AL", "Alabama", "The Heart of Dixie" },
                    new object[] { "AK", "Alaska", "The Land of the Midnight Sun" },
                    new object[] { "AZ", "Arizona", "The Grand Canyon State" },
                    new object[] { "AR", "Arkansas", "The Natural State" },
                    new object[] { "CA", "California", "The Golden State" },
                    new object[] { "CO", "Colorado", "The Mountain State" },
                    new object[] { "CT", "Connecticut", "The Constitution State" },
                    new object[] { "DE", "Delaware", "The First State" },
                    new object[] { "DC", "District of Columbia", "The Nation's Capital" },
                    new object[] { "FL", "Florida", "The Sunshine State" },
                    new object[] { "GA", "Georgia", "The Peach State" },
                    new object[] { "HI", "Hawaii", "The Aloha State" },
                    new object[] { "ID", "Idaho", "Famous Potatoes" },
                    new object[] { "IL", "Illinois", "The Prairie State" },
                    new object[] { "IN", "Indiana", "The Hospitality State" },
                    new object[] { "IA", "Iowa", "The Corn State" },
                    new object[] { "KS", "Kansas", "The Sunflower State" },
                    new object[] { "KY", "Kentucky", "The Bluegrass State" },
                    new object[] { "LA", "Louisiana", "The Bayou State" },
                    new object[] { "ME", "Maine", "The Pine Tree State" },
                    new object[] { "MD", "Maryland", "Chesapeake State" },
                    new object[] { "MA", "Massachusetts", "The Spirit of America" },
                    new object[] { "MI", "Michigan", "Great Lakes State" },
                    new object[] { "MN", "Minnesota", "North Star State" },
                    new object[] { "MS", "Mississippi", "Magnolia State" },
                    new object[] { "MO", "Missouri", "Show Me State" },
                    new object[] { "MT", "Montana", "Big Sky Country" },
                    new object[] { "NE", "Nebraska", "Beef State" },
                    new object[] { "NV", "Nevada", "Silver State" },
                    new object[] { "NH", "New Hampshire", "Granite State" },
                    new object[] { "NJ", "New Jersey", "Garden State" },
                    new object[] { "NM", "New Mexico", "Land of Enchantment" },
                    new object[] { "NY", "New York", "Empire State" },
                    new object[] { "NC", "North Carolina", "First in Freedom" },
                    new object[] { "ND", "North Dakota", "Peace Garden State" },
                    new object[] { "OH", "Ohio", "The Heart of it All" },
                    new object[] { "OK", "Oklahoma", "Oklahoma is OK" },
                    new object[] { "OR", "Oregon", "Pacific Wonderland" },
                    new object[] { "PA", "Pennsylvania", "Keystone State" },
                    new object[] { "RI", "Rhode Island", "Ocean State" },
                    new object[] { "SC", "South Carolina", "Nothing Could be Finer" },
                    new object[] { "SD", "South Dakota", "Great Faces, Great Places" },
                    new object[] { "TN", "Tennessee", "Volunteer State" },
                    new object[] { "TX", "Texas", "Lone Star State" },
                    new object[] { "UT", "Utah", "Salt Lake State" },
                    new object[] { "VT", "Vermont", "Green Mountain State" },
                    new object[] { "VA", "Virginia", "Mother of States" },
                    new object[] { "WA", "Washington", "Green Tree State" },
                    new object[] { "WV", "West Virginia", "Mountain State" },
                    new object[] { "WI", "Wisconsin", "America's Dairyland" },
                    new object[] { "WY", "Wyoming", "Like No Place on Earth" }
    <head runat="server">
        <form id="form1" runat="server">
                <ext:ResourceManager runat="server" />
                    runat="server" ID="cb1"
                    FieldLabel="Select a single state"
                    QueryMode="Local" ValueField="abbr"
                        <ext:Store runat="server" Data="<%# TestData %>" AutoDataBind="true">
                                <ext:Model runat="server">
                                        <ext:ModelField Name="abbr" />
                                        <ext:ModelField Name="name" />
                                        <ext:ModelField Name="slogan" />
                                <ext:ArrayReader />
                <ext:Button runat="server" Text="Get valueField (abbr) from selection above" Handler="App.lbl1.setText(App.cb1.getValue());" />
                <ext:Label runat="server" ID="lbl1" />
    Notice this is a modified version of the ComboBox overview example.

    Well, hope this helps! If not, please modify the above example with what it takes to reproduce the issue, and we get to the bottom of it!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Dear fabricio,

    I discovered strange behavior in this issue.

    Consider this scenario:

    1. When the page loaded first time, the ComboBox will be loaded and our currency will be selected by default:

        Function loadCurrency() As Boolean
            Dim strSQL As String = clsSQL.getCurrencyList()
            Dim ds As DataSet = clsDB.getData(strSQL)
            If Not ds Is Nothing Then
                If ds.Tables(0).Rows.Count > 0 Then
                    Dim myStore2 = ddlPaymentCurrency.GetStore
                    myStore2.DataSource = ds.Tables(0)
                    ddlPaymentCurrency.SelectedItems.Add(New Ext.Net.ListItem("Currency A", "ABC"))
                End If
            End If
            Return True
        End Function
    2. When I submit the page directly, without any changes in the ComboBox, the value I'm getting is (Currency A).

    3. When I change the ComboBox selection to any other value i.e. Currency B, the value submitted is correct.

    4. Even when I re-select the default currency (Currency A), then the submitted value is correct (ABC).

    Note that the Button Click DirectEvents and ComboBox are in two different FormPanel.

    Do I'm using the right code to set the default selection for the ComboBox?!

  4. #4
    Hello Alaswad!

    Maybe you want to just
    ddlPaymentCurrency.SelectedItems.Add(New Ext.Net.ListItem("ABC"))
    On your line 13!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 4
    Last Post: Sep 28, 2011, 8:57 AM
  2. Replies: 9
    Last Post: Sep 15, 2011, 1:58 PM
  3. Replies: 6
    Last Post: Aug 01, 2011, 4:53 PM
  4. Combobox value with ExtraParams
    By ulrikn in forum 1.x Help
    Replies: 1
    Last Post: Feb 09, 2011, 10:46 AM
  5. [CLOSED] Add selected items to ExtraParams for MultiSelect
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 20, 2010, 8:40 PM

Posting Permissions