PDA

View Full Version : ComboBox acts funny



Ooypunk
16 Jan 2011, 3:34 PM
I have this ComboBox that is giving me a bit of trouble. It's working fine, until I try to set the value of it with:

var form = panel_orders_form.getForm();
form.findField('id_bedrijf').setValue(klantId);
form.submit();The manual says this:

If the value finds a match, the corresponding record text will be displayed in the field.It does set the correct value in the box, only the value (that is, the 'id_bedrijf': an ID, an integer) is shown, while it should display the corresponding text.

I hope this is enough information to help, if not, please say so.

devtig
16 Jan 2011, 10:46 PM
Can you post the config of your combobox here?

Condor
17 Jan 2011, 12:35 AM
How is Ext supposed to know the company name if the combobox store isn't loaded?

ps. bedrijf == klant?

Ooypunk
17 Jan 2011, 9:12 AM
Can you post the config of your combobox here?Sure:

var combo_klantnaam = new Ext.form.ComboBox({
store: combo_klantnaam_store,
typeAhead: true,
typeAheadDelay: 0,
queryDelay: 0,
minChars: 0,
triggerAction: 'all',
emptyText:'Kies een klant...',
selectOnFocus:true,
fieldLabel: 'Klantnaam',
valueField: 'id',
displayField: 'klantnaam',
hiddenName: 'id_bedrijf',
allowBlank: false,
forceSelection: true,
width: 129
});
And the store that goes with it:

var combo_klantnaam_store = new Ext.data.ArrayStore({
autoDestroy: true,
idIndex: 0,
fields: [
{name: 'id', type: 'integer'},
{name: 'klantnaam', type: 'string'}
],
baseParams: { is_klant: '1' },
url: 'php/ajax/get_bedrijven.php'
});

@Condor: as you see above, the combobox store is loaded, and the combobox is filled.

On your PS: the store sends in the baseParams: is_klant=1, to load only the 'klanten':
- bedrijf == company
- klant = customer
-> a klant is a bedrijf, but not necessarily the other way round ;) (the table contains other companies as well, for example suppliers)

Hope this clarifies.

Condor
17 Jan 2011, 11:29 PM
@Condor: as you see above, the combobox store is loaded, and the combobox is filled.

Actually, I don't see it being loaded anywhere.

That means the combobox will load when the dropdown is triggered for the first time, which is too late, because the combobox value will have been initialized by then (and no display text was found).

I recommend using this patch (http://www.sencha.com/forum/showthread.php?75751-OPEN-42-ComboBox-s-setValue-call-with-a-remotely-loaded-Store&p=400274#post400274).

Ooypunk
18 Jan 2011, 1:20 PM
That means the combobox will load when the dropdown is triggered for the first time, which is too late, because the combobox value will have been initialized by then (and no display text was found).Ah, that would explain why the box could find the text when I opened the list (trigger the dropdown): that's the first time the list is loaded. It would also explain why the text could be found when the list was used once before: list was loaded already. It all makes sense now, thanks! :)

I'll go and try the patch now.

Ooypunk
18 Jan 2011, 2:10 PM
I tried, and for now I think the option autoLoad:true works even better.
Thanks though, I wouldn't have thought about that without you pointing me in the right direction!