0

I am new to extJS, and trying to implement the following functionality:

I have two select drop down menus, transformed using extJS. How can I make sure that if a value in one combo box is selected, the other value should be set back to some default value?

Thanks.

Edited: Code till now:

Ext.onReady(function(){ 

var converted = new Ext.form.ComboBox({ 

    typeAhead: true, 
    triggerAction: 'all', 
    transform:'id_Select1', 
    width:600, 
    forceSelection:true, 
    emptyText:'Select' 

}); 

var convertedCdr = new Ext.form.ComboBox({ 
    typeAhead: true, 
    triggerAction: 'all', 
    transform:'id_select2', 
    width:600, 
    forceSelection:true, 
    emptyText:'Select' 
}); 
});

I am using ColdFusion to query the database and populate the drop down menus:

<cfquery name="getData1" datasource="abc">
   SELECT * FROM table1
</cfquery>

<cfquery name="getData2" datasource="abc">
   SELECT * FROM table2
</cfquery>

<select name="select1" id="select1">
  <cfoutput query="getData1">
       <option value="#getData1.Id#">#getData1.name#</option>
  </cfoutput>
</select>

 <select name="select2" id="select1">
  <cfoutput query="getData2">
       <option value="#getData2.Id#">#getData2.name#</option>
  </cfoutput>
</select>

1 Answer 1

3

EDITED - I haven't used CFM... you'll need to figure out how to load your CF using data stores to use this technique.

You will need to add a listener for the select event on the combo:

xtype: 'combo',
id   : 'firstComboID',
listeners: {
  select: function(combo,  record,  index ) {
    var selVal = Ext.getCmp('firstComboID').getValue();
    var secondCombo = Ext.getCmp('secondComboID');
    secondCombo.store.reload({params: {yourParameterName: selVal}});
}

Basically you are doing the following here:

  1. Get the value selected in the first combo
  2. Get a reference to the second combo's data store
  3. Reload the store of the second combo box using the selected value from the first combo
8
  • Here is the code I have till now `Ext.onReady(function(){ var converted = new Ext.form.ComboBox({ typeAhead: true, triggerAction: 'all', transform:'id_Select1', width:600, forceSelection:true, emptyText:'Select' } }); var convertedCdr = new Ext.form.ComboBox({ typeAhead: true, triggerAction: 'all', transform:'id_select2', width:600, forceSelection:true, emptyText:'Select' }); }); I have two select drop downs populated from database: Not sure if combo.store would work in my case?
    – DG3
    Nov 15, 2010 at 18:39
  • Can you edit your question with your source code using the code formatting in the WYSIWYG editor please? Where do you your combo boxes get their data from then? I don't see any configuration options.
    – It Grunt
    Nov 15, 2010 at 18:58
  • I need to see how you are loading the data... When you use transform in the configuration, the DOM elements are converted to an ArrayStore automatically. Can you edit your question to show the layout and how the data is loaded?
    – It Grunt
    Nov 15, 2010 at 19:54
  • I updated my question with html code too. I hvae another question. In javascript, I use document.all.select1.value to get the value of an element. What is the equivalent in extJS?
    – DG3
    Nov 15, 2010 at 20:03
  • Ext.getCmp('fieldDomID').value
    – It Grunt
    Nov 15, 2010 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.