Results 1 to 4 of 4

Thread: Combobox sends Text instead of value

  1. #1
    Ext JS Premium Member
    Join Date
    Jan 2008
    Posts
    123
    Vote Rating
    0
      0  

    Default Combobox sends Text instead of value

    Hi,

    I guess I am doing something wrong but I don't see what. Can someone help me please?

    I have a very simple combobox, which I feed with a 2-dimensional array of value text. When I press submit the text is sent and not the value. In the combobox choices I see the texts.

    Code:
    <html>
    <head>
    <script type="text/javascript" src="../extjs/adapter/ext/ext-base.js?v=3331"></script>
    <script type="text/javascript" src="../extjs/ext-all-debug.js?v=3331"></script>			
    
    </head>
    <body>
    
    <form>
    	<input id="combo" name="combo" type="text" />
    	<input type="submit" name="send" />
    </form>
    
    <script type="text/javascript">
        //<![CDATA[
    	Ext.onReady(function(){
    	    var arrayCombo = [["a", "apple"], ["b", "banana"]];
    	    var combo = new Ext.form.ComboBox({
    		typeAhead: true, 
    		store: arrayCombo, 
    		triggerAction: 'all', 
    		applyTo:'combo', 
    		width:200, 
    		editable:false, 
    		selectOnFocus:true,
    		value: "b",
    		mode: 'local',
    		forceSelection:true
    	    });	
    	});
        //]]>
    </script>
    </body>
    </html>
    
    The combobox shows normally with all the fruit texts, but when I submit, the text is sent and not the value!!!

  2. #2
    Sencha User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,964
    Vote Rating
    930
      0  

    Default

    You haven't specified a valueField for your combo.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3
    Sencha User
    Join Date
    Feb 2008
    Posts
    17
    Vote Rating
    0
      0  

    Default

    I have the same problem.
    From the documentation, when a 2-dimensional array is passed as a store, it assumes that the first entry in every item is the value and the second is the text but from my experience it isn't. It always sends the text.

    Also I tried creating a SimpleStore from the multidimensional array and setting displayField and valueField explicitly but it's ignoring the valueField option since it's sending the shown text.

    I'm using Ext 2.1 with prototype adapter (I don't know if it matters).

  4. #4
    Sencha - Community Support Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Redwood City
    Posts
    30,740
    Vote Rating
    79
      0  
    Longtime Sencha engineer. Now surplus to requirements apparently...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •