PDA

View Full Version : Cascading ComboBox



sumithjoy
29 Jun 2010, 1:43 PM
Hi,

I have a grid which populate a list of records from DB. while double click on a row, i have created a window (contains a formPanel inside) which will display all the fields from that row. In this window, I have two cascading comboboxes, one for country and one for states. My problem is that while I use setValue for country combobox, its showing the correct country name , but when I use setValue for state combobox, it shows the exact text which I gave as setValue. The JsonStore for state combobox is loading(using external php) according to the value got from country combobox. The reason might be when I call setValue for state combobox, the JsonStore for this may not be completely loaded. I m not sure. Please help me. The code is added below.

var jsonStoreCountry = new Ext.data.JsonStore({
url: 'listcountry.php',
root:'rootAttr',
fields: ['code', 'name']
});
jsonStoreCountry.load();

var jsonStoreState = new Ext.data.JsonStore({
url: 'liststate.php',
root:'rootAttr',
fields: ['code', 'name']
});


var doRowDblClick = function(thisGrid) {
var record = thisGrid.selModel.getSelected();
jsonStoreState.load({params:{country_hidden: record.get('country_id')}});

Ext.getCmp('propertyName').setValue(record.get('property_name'));
Ext.getCmp('propertyAddress1').setValue(record.get('property_add1'));
Ext.getCmp('propertyAddress2').setValue(record.get('property_add2'));
Ext.getCmp('propertyEmpCount').setValue(record.get('employee_count'));
Ext.getCmp('propertyWebSite').setValue(record.get('website'));
Ext.getCmp('country').setValue(record.get('country_id'));
//Ext.getCmp('country').fireEvent("select");
Ext.getCmp('propertyCity').setValue(record.get('city'));
Ext.getCmp('propertyPostalCode').setValue(record.get('postal_code'));
Ext.getCmp('propertyPhone').setValue(record.get('phone'));
Ext.getCmp('propertyFax').setValue(record.get('fax'));
Ext.getCmp('propertyEmail').setValue(record.get('email'));
Ext.getCmp('state').setValue(record.get('state_id')); // it shows the exact state_id, not the state name in the combo.

Ext.propertyMasterEdit.show();

Animal
29 Jun 2010, 2:05 PM
Why don't you use the same names in your form Fields and your Record Fields???

sumithjoy
21 Jul 2010, 12:35 PM
Thank you for the help. It worked.

dorgan
21 Jul 2010, 4:22 PM
For the love of god....please look into using the ref option Ext.getCmp() is not your friend...

http://www.sencha.com/deploy/dev/docs/source/Component.html#cfg-Ext.Component-ref