View Full Version : FormPanel CRUD combobox

13 Jul 2010, 12:39 AM
I have formpanel that i load via load() method. I have problem with combobox elements - cant load them correctly. Each combo has a hidden field and defines like:

xtype : 'combo',
fieldLabel : 'Timezone',
displayField : 'title',
valueField : 'id',
hiddenName : 'time_zone_id',
name : 'time_zone_value',
store : new Ext.data.JsonStore({
url : '/common/get_timezone',
fields: ['id', 'title']

So, when i initialize this combo via load() method i need to set up values that comes from the server. From server i have: time_zone_id and time_zone_value fields in json response. I've tried different combinations, but it doesnt want to render it as expected. Does someone have a solution or ideas?

13 Jul 2010, 1:08 AM
You should define a mapping for your fields if you want to give them a name different from the json response

fields: [
{name: 'id', mapping: 'time_zone_id'},
{name: 'title', mapping: 'time_zone_value'}

try to debug inside your store to see if the values are correctly loaded.

13 Jul 2010, 1:15 AM
tomcruz, dont look at that jsonstore) it works great. The problem is - how to load hiddenValue and displayValue to combo via Ext.form.BasicForm.load().

For example, for textfield you should return from server something like this:

success: true,
data : {
textfieldname: 'value'

but combo definitely has two different values: hidden one and display. How to figure out with this?

13 Jul 2010, 1:27 AM
Oh ok !
I think the response only needs to have the "time_zone_id" field, so that the load action sets your combo's value to the id (the label should be automatically displayed since your store is working)
If I recall correctly (it's been a while I've worked on this hiddenName business) you don't need both a name AND an hiddenName configuration in your combo unless of course you want to send both the id and label to the server. Which means you also don't need the time_zone_value field in the server's response.

13 Jul 2010, 1:51 AM
time_zone_value needs because store doesnt have autoLoad: true. I dont need to load store before user first time click on it. Of course we dont need time_zone_id and time_zone_value to be sent to the server both. That's why we have hidden field which stores time_zone_id as value. But when we initialize form with load() method we cant fill these two fields (hidden and display) correctly...

13 Jul 2010, 2:18 AM
right, the store isn't loaded my bad! i used to handle this differently :)

I remember now, there's something with the hiddenName config: In ext 2, specifying a hiddenName made the ext engine delete the "name" attribute of the combo to prevent the label to be submitted. Now this works with the submitValue parameter that lets you control if a field is submitted in general. The property defaults to true but on comboBoxes it is undefined and passed to false if a hiddenName is specified.

Maybe what's happening to you is that your combo loses its "name" property on render which screws the load action's result. Or I might be totally mistaken. Try to put submitValue: true on your combo ?