PDA

View Full Version : Still about ComboBox...


franzisk
05-19-2007, 07:36 AM
I need to do something (load states to the choosen country) when the value in the ComboBox field change, it can be with setValue(...) or when user selects in the dropdown list (this last one I have it working).


So I have this:
var dsCountries = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'action_getLocation.php?id=1'
}),
reader: new Ext.data.JsonReader({
root: 'countries',
totalProperty: 'totalCount',
id: 'id'
}, [
{name: 'abr'},
{name: 'id', type:'int' },
{name: 'name'}
])
});

var comboProfileCountry = new Ext.form.ComboBox({
store: dsCountries,
displayField:'name',
valueField:'id',
loadingText: 'Loading...',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a country...',
selectOnFocus:true,
lazyRender:true,
forceSelection:true
});

comboProfileCountry.applyTo('PROFILE-COUNTRY');
dsCountries.on('load', function(){
comboProfileCountry.setValue(<?=$rec['countryID'];?>);
// Here I need to get the selected 'abr' of the selected item
},
this,
{single: true}
);
dsCountries.load();

rqmedes
05-24-2007, 01:59 AM
Sorry I don't exactly understand what you are trying to do, are you selecting one combo box (country) and then trying to populate a list of states?

If so you could add a paramater for country to the states data store and then reload the data leaving the server to handle the filtering

comboProfileCountry.on("select", function(){
state.store.baseParams = {countryID: comboProfileCountry.getValue()};
state.store.load();
});

franzisk
05-24-2007, 04:03 AM
This was solved some time ago, but thanks for your reply anyway.