Results 1 to 3 of 3

Thread: Filtering comboboxes after loading a form

  1. #1

    Default Filtering comboboxes after loading a form

    Hello all,
    I have a form with a textfield (username) and 3 comboboxes (State, Country, City):
    selecting a State filters CountryCombo, selecting a Country filters CityCombo. It works, but when I load data of an existing record, comboboxes are correctly selected but not filtered.
    There is my code

    PHP Code:
    ....
    var 
    inMainFile='usrFile.php';

    var 
    storeState=new ed.JsonStore({
        
    url:inMainFile,baseParams:{op:'seSearch'},
        
    root:'state',fields:['STATE_ID','STATE_DESCR']
    });
    var 
    comboState=new ef.ComboBox({
        
    name:'STATE_ID',
        
    fieldLabel:'State'
        
    mode:'remote',store:storeState,
        
    selectOnFocus:true,triggerAction:'all',typeAhead:true,
        
    hiddenName:'STATE_ID',valueField:'STATE_ID',displayField:'STATE_DESCR',
        
    onSelect:function(record) {
            
    this.setValue(record.data.STATE_ID);
            
    this.collapse();
            if(
    storeCountry.getCount()>0) {
                
    comboCountry.clearValue();
                
    storeCountry.reload();
            }
        }
    });
    var 
    storeCountry=new ed.JsonStore({
        
    url:inMainFile,baseParams:{op:'blSearch'},
        
    root:'country',fields:['COUNTRY_ID','COUNTRY_DESC']
    });
    storeCountry.on('beforeload',function() {
        if (
    comboState.value!="undefined" && comboState.value>0)
            
    storeCountry.baseParams={op:'blSearch',ft:comboState.value};
    });
    var 
    comboCountry=new ef.ComboBox({
        
    name:'COUNTRY_ID',
        
    fieldLabel:'Country',
        
    mode:'remote',store:storeCountry,
        
    selectOnFocus:true,triggerAction:'all',typeAhead:true,
        
    hiddenName:'COUNTRY_ID',valueField:'COUNTRY_ID',displayField:'COUNTRY_DESC',
        
    onSelect:function(record) {
            
    this.setValue(record.data.COUNTRY_ID);
            
    this.collapse();
            if(
    storeCities.getCount()>0) {
                
    comboCities.clearValue();
                
    storeCities.reload();
            }
        }
    });
    var 
    storeCities=new ed.JsonStore({
        
    url:inMainFile,baseParams:{op:'saSearch'},
        
    root:'cities',totalProperty:'totale',
        
    fields:['CITY_ID','CITY_DESC']
    });
    storeCities.on('beforeload',function() {
        if (
    comboCountry.value!="undefined" && comboCountry.value>0)
            
    storeCities.baseParams={op:'saSearch',ft:comboCountry.value};
    });
    var 
    comboCities=new ef.ComboBox({
        
    name:'CITY_ID',
        
    mode:'remote',store:storeCities,
        
    selectOnFocus:true,triggerAction:'all',typeAhead:true,
        
    hiddenName:'CITY_ID',valueField:'CITY_ID',
        
    displayField:'CITY_DESC'
    });

    .....

    var 
    objReader=new ed.JsonReader({
        
    root:'modName',
        
    fields:[{name:'USR_ID',type:'int'},{name:'STATE_ID',type:'int'},
                        {
    name:'COUNTRY_ID',type:'int'},
                        {
    name:'CITY_ID',type:'int'},'userName']
    });
    var 
    UserForm=new ef.FormPanel({
        
    url:inMainFile,
        
    reader:objReader,
        
    baseParams:{op:'saveUsr'},
        
    items:[new ef.Hidden({name:'USR_ID',value:Rec}),
            {
    xtype:"textfield",fieldLabel:"Name",name:"userName",allowBlank:false},
            {
    xtype:"fieldset",title:"Position",
                
    items:[comboState,comboCountry,comboCities]}]
    });

    if (
    Rec) {
        
    storeState.load({callback:function() {
            
    storeCountry.load({callback:function() {
                
    storeCities.load({callback:function() {
                    
    UserForm.form.load({
                        
    url:inMainFile,
                        
    params:{op:'loadValues',idUsr:Rec}
                    });
                }});
                
    comboCities.mode='local';
            }});
            
    comboCountry.mode='local';
        }});
        
    comboState.mode='local';

    Any idea?
    Thanks in advance

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    Combobox uses filtering itself and this will replace your own filter.

    You can disable combobox filtering with:

    Code:
    triggerAction: 'all',
    lastQuery: '',

  3. #3

    Default Well, I'd like to have my combos filtered

    Thanks, but what i'd like is finding my combobox filtered after loading the form.
    For example, if I've a user from US, StateCombo will show US, and CountryCombo will show only US Countries, and so for Cities. Now CountryCombo contains all Countries of the world.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •