Results 1 to 2 of 2

Thread: displayField/valueField/hidddenName in combobox

  1. #1
    Sencha User
    Join Date
    Apr 2008
    Posts
    365

    Post displayField/valueField/hidddenName in combobox

    Hello,

    I have some values in a combobox like:
    Code:
    id	url		name
    1	/ 		Homepage
    2	/page1.htm	Page1
    3	/page2.htm	Page2
    4	/page6.htm	Page6
    and so on.

    This is the way I create the combobox:
    Code:
    {
    xtype: 'combo',
    value:'/page1.htm",
    name: 'id_visible',
    typeAhead: true,
    forceSelection: false,
    triggerAction: 'all',
    minChars:3,
    selectOnFocus: true,
    displayField:'name',
    valueField:'id',
    hiddenName:'id_post',
    tpl: '<tpl for=\".\"><div class=\"x-combo-list-item\">{name} ({url})</div></tpl>',
    store:	new Ext.data.Store(
    {	autoLoad: true,     
    	proxy: new Ext.data.HttpProxy(
    	{	url: '/get_store.php', 
    		method: 'POST'
    	}),
    	reader: new Ext.data.ArrayReader(
    	{	root: 'data',
    		totalProperty: 'total',
    		id: 0
    	}, 												 
    	[	{ name: 'id', type: 'string' },
    		{ name: 'url', type: 'string' },
    		{ name: 'name', type: 'string' }
    	])
    })
    }
    So what happens?

    If if open the comboxbox and choose a value, the correct value (a number, the id) is posted in id_post.
    If if DO NOT open the comboxbox, the original value (a string "/page1.htm") is posted in id_post.

    How can I make the combobox post the id as a number in both situations?

  2. #2
    Sencha User
    Join Date
    Apr 2008
    Posts
    365

    Default

    Ah, you have to set a hiddenValue as well. Now it works.

Similar Threads

  1. How to get both ValueField and displayField value in comboBox
    By bhanuprakash_kavi in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 4 Jul 2012, 1:54 AM
  2. The comboBox valueField and displayField
    By wguo in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 13 Feb 2011, 2:14 AM
  3. combobox | displayField | valueField
    By thatcoder in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 30 Apr 2009, 3:11 PM
  4. combobox valueField vs displayField?
    By rledousa in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 5 Nov 2007, 1:24 PM
  5. Combobox valueField vs. displayField
    By momo in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 4 Jul 2007, 5:43 AM

Posting Permissions

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