PDA

View Full Version : Cascading Combobox no longer working



Tumac
2 Sep 2010, 12:58 PM
I have a cascaded combobox on a form that works on select and save of the form, but when you pull the form back up, the display of the cascaded combo just shows the id value and not the name value. This used to work and just stopped working. I did throw in the 3.3B2 library recently and will roll back, but thought i would get this posted.

Combo 1 selects a Mill. Upon selection of the mill the Contact combobox filters contacts for that mill by Name and when the form is saved, the keyid value(hiddenName) for the Contact is saved.

This works fine and when the form is reloaded the MillName is present, but the keyid value shows in the cascaded/linked box instead of the linked name:



},{
xtype: 'combo'
,editable: false
,width:300
,fieldLabel: 'Mill'
,name: 'comboMill'
,displayField:'millName'
,valueField: 'millID'
,hiddenName: 'millID'
,triggerAction:'all'
,store: {
xtype: 'jsonstore'
,url: '?c=lookup&m=mills'
,fields: ['millID','millName']
,autoLoad:false
}
,listeners:
{select: {
fn: function(combo,record,value)

{
var conbox = Ext.getCmp('contact');
conbox.clearValue();
conbox.store.load({
params:{
millID: record.data.millID
}
});
}
}}
},{
xtype: 'combo'
,editable: false
,width:300
,id: 'contact'
,fieldLabel: 'Contact'
,name: 'comboContact'
,displayField:'conName'
,valueField: 'conID'
,hiddenName: 'conID'
,triggerAction:'all'
,mode: 'local'
,store: {
xtype: 'jsonstore'
,url: '?c=lookup&m=contacts'
,fields: ['conID','conName']
,autoLoad:false
}
}]

Tumac
2 Sep 2010, 1:12 PM
I rolled back to 3.2 and same result. What is interesting is if I change the Contact name and save the form. All the records with that contact display properly (because it is currently loaded)?

Condor
3 Sep 2010, 1:31 AM
The store of the second combobox needs to contain the text for the value you are setting.

grunichev
3 Sep 2010, 3:06 AM
Does anyone know any extension for multi-level combobox (something like drop-down menu) rather than 2 different cascading selectboxes?

Condor
3 Sep 2010, 3:33 AM
The Simple Tasks example in the ext-air package contains a TreeSelector component (doesn't require Air).

Animal also created a component that does the same (see the user extensions forum).

Tumac
3 Sep 2010, 8:01 AM
The store does contain the text of the name. I have even set the store to autoload to make sure it is there in advance and it still has same result.

the store does contain the text conName. Am I missing your point?

Condor
3 Sep 2010, 9:57 PM
Loading is asynchronous. Are you SURE the store is loaded before you set the value?

If not then try this override (http://www.sencha.com/forum/showthread.php?75751-OPEN-42-ComboBox-s-setValue-call-with-a-remotely-loaded-Store&p=400274#post400274).

Tumac
8 Sep 2010, 11:25 AM
I can see the JSON data and the store is loaded prior to rendering the form . I will try the override.

Thanks.

Tumac
8 Sep 2010, 1:21 PM
I added the override to a file called overrides.js which I load after I load the main EXT and UX.js files. Is there something else I should be doing?

Tumac
8 Sep 2010, 5:21 PM
Your right about the store loading. It loads when I choose the superseding combo and filters it right there. Therfore any record with that value shows but not the others. Although, when I choose a record that is bound to the form, I also have the conName.

Perhaps my implementation of the cascaded combo is not a good one for form bound records?

Tumac
8 Sep 2010, 6:16 PM
Set dependent combo to autoload:true with all possible values, then listener filters choice instead of reloading store with specific millID.



},{
xtype: 'combo'
,editable: false
,width:300
,fieldLabel: 'Mill'
,name: 'comboMill'
,displayField:'millName'
,valueField: 'millID'
,hiddenName: 'millID'
,triggerAction:'all'
,store: {
xtype: 'jsonstore'
,url: '?c=lookup&m=mills'
,fields: ['millID','millName']
,mode: 'local'
,autoLoad:false
}
,listeners:
{select: {
fn: function(combo,value) {
var conbox = Ext.getCmp('contact');
console.log(combo);
conbox.clearValue();
conbox.store.filter('millID',combo.getValue());
}
}}
},{
xtype: 'combo'
,editable: false
,width:300
,id: 'contact'
,fieldLabel: 'Contact'
,name: 'comboContact'
,displayField:'conName'
,valueField: 'conID'
,hiddenName: 'conID'
,triggerAction:'all'
,lastQuery:''
,store: {
xtype: 'jsonstore'
,url: '?c=lookup&m=contacts'
,fields: ['millID','conID','conName']
,autoLoad:true
}
}]