PDA

View Full Version : displayField/valueField/hidddenName in combobox



wuschba
16 Nov 2010, 1:23 AM
Hello,

I have some values in a combobox like:


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:


{
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?

wuschba
16 Nov 2010, 1:28 AM
Ah, you have to set a hiddenValue as well. Now it works.