We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15827
    • 3 Posts
    Hello,

    I have a grid that loads an update window. In this update window are several combo boxes, one that is loaded remotely and the rest by data stores. The local data stores combo boxes show their respective values from the database but the remotely loaded one shows Empty Text. I’ve tried setting lazyInit to off but that didn’t help. I’ve found a load listener on the data store but since the MODx Combo Box extends the general combo box (configures it nicely for ModX connections), I don’t setup my own data store. Is the solution to use a normal combo box with my own remote data store which then will call upon the record to do cmb.setValue(record.field) when the data store is loaded? I presume there is a simpler way and I am just missing a configuration item.

    Here is the code I am currently using:

    var nameList = function(config) {
        config = config || {};
        Ext.applyIf(config, {
    	 fieldLabel: _('estates.album')
    	,name: 'album'
    	,width: 300
    	,hiddenName: 'album'
    	,emptyText: 'Select album...'
    	,typeAhead: true
    	,triggerAction: 'all'
    	,lazyInit: false
    	,valueField: 'id'
    	,displayField: 'name'
    	,fields: ['id','name']
    	,url: '/assets/components/gallery/connector.php'
    	,baseParams: {
    	    action: 'mgr/album/getlist',
    	    combo: true
    	}
        });
       
        nameList.superclass.constructor.call(this, config);
    };
    
    Ext.extend(nameList, MODx.combo.ComboBox);
    Ext.reg('albums-combo-names', nameList);


    Thanks in advance.
      • 28215
      • 4,149 Posts
      1. Can you post *all* the code for the combobox, including how this cb is loaded into the Window you’re using?
      2. Why do you have lazyInit: false?
      3. You shouldn’t need triggerAction: ’all’
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 15827
        • 3 Posts
        The reason why I have lazyInit false is from the documentation I was under the impression that lazyInit caused the values to be grabbed from the database only when the select is clicked. Therefore I set it to false to try to force it to load the combo box items right away (thinking this may have caused the issue). I’ve removed triggerAction and lazyInit. Below is what I believe to be the relevant code chunks (can paste more of the file if need be).

                // grid menu configuration to spawn update window
        	,updateEstate: function(btn,e) {
        	    if (!this.updateEstateWindow) {
        		this.updateEstateWindow = MODx.load({
        		    xtype: 'estates-window-estate-update'
        		    ,record: this.menu.record
        		    ,listeners: {
        			'success': {fn:this.refresh,scope:this}
        		    }
        		});
        	    } else {
        		this.updateEstateWindow.setValues(this.menu.record);
        	    }
        	    this.updateEstateWindow.show(e.target);
        	}
        	,
        
        var nameList = function(config) {
            config = config || {};
            Ext.applyIf(config, {
        	 fieldLabel: _('estates.album')
        	,name: 'album'
        	,width: 300
        	,hiddenName: 'album'
        	,emptyText: 'Select album...'
        	,typeAhead: true
        	,valueField: 'id'
        	,displayField: 'name'
        	,fields: ['id','name']
        	,url: '/assets/components/gallery/connector.php'
        	,baseParams: {
        	    action: 'mgr/album/getlist',
        	    combo: true
        	}
            });
           
            nameList.superclass.constructor.call(this, config);
        };
        
        Ext.extend(nameList, MODx.combo.ComboBox);
        Ext.reg('albums-combo-names', nameList);
        
        
        
        
        Estates.window.UpdateEstate = function(config) {
            config = config || {};
            Ext.applyIf(config,{
                title: _('estates.estate_update')
                ,url: Estates.config.connectorUrl
                ,width: 470
                ,baseParams: {
                    action: 'mgr/estate/update'
                }
                ,fields: [{
                	    xtype: 'hidden'
                	    ,name: 'id'
                	},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.tag')
        		    ,name: 'tag'
        		    ,width: 300
        		},{
        		    xtype: 'combo'
        		    ,fieldLabel: _('estates.company')
        		    ,name: 'company'
        		    ,width: 300
        		    ,hiddenName: 'company'
        		    ,emptyText: 'Select company...'
        		    ,store: company_store
        		    ,valueField: 'value'
           		    ,displayField: 'text'
        		    ,triggerAction: 'all'
        		    ,mode: 'local'
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.name')
        		    ,name: 'name'
        		    ,width: 300
        		},{
        		    xtype: 'textarea'
        		    ,fieldLabel: _('estates.description')
        		    ,name: 'description'
        		    ,width: 300
        		},{
        		    xtype: 'combo'
        		    ,fieldLabel: _('estates.type')
        		    ,name: 'type'
        		    ,width: 300
        		    ,hiddenName: 'type'
        		    ,emptyText: 'Select type...'
        		    ,store: type_store
        		    ,valueField: 'value'
           		    ,displayField: 'text'
        		    ,triggerAction: 'all'
        		    ,mode: 'local'
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.price')
        		    ,name: 'price'
        		    ,width: 300
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.bedrooms')
        		    ,name: 'bedrooms'
        		    ,width: 300
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.parking')
        		    ,name: 'parking'
        		    ,width: 300
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.contact_number')
        		    ,name: 'contact_number'
        		    ,width: 300
        		},{
        		    xtype: 'combo'
        		    ,fieldLabel: _('estates.availability')
        		    ,name: 'availability'
        		    ,width: 300
        		    ,hiddenName: 'availability'
        		    ,emptyText: 'Select availability...'
        		    ,store: availability_store
        		    ,valueField: 'value'
           		    ,displayField: 'text'
        		    ,triggerAction: 'all'
        		    ,mode : 'local'
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.street_number')
        		    ,name: 'street_number'
        		    ,width: 300
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.street')
        		    ,name: 'street'
        		    ,width: 300
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.city')
        		    ,name: 'city'
        		    ,width: 300
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.province')
        		    ,name: 'province'
        		    ,width: 300
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.country')
        		    ,name: 'country'
        		    ,width: 300
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.requirements')
        		    ,name: 'requirements'
        		    ,width: 300
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.bathrooms')
        		    ,name: 'bathrooms'
        		    ,width: 300
        		},{
        		    xtype: 'combo'
        		    ,fieldLabel: _('estates.heating')
        		    ,name: 'heating'
        		    ,width: 300
        		    ,hiddenName: 'heating'
        		    ,emptyText: 'Select heating...'
        		    ,store: heating_store
        		    ,valueField: 'value'
           		    ,displayField: 'text'
        		    ,triggerAction: 'all'
        		    ,mode : 'local'
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.pets')
        		    ,name: 'pets'
        		    ,width: 300
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.backyard')
        		    ,name: 'backyard'
        		    ,width: 300
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.garage')
        		    ,name: 'garage'
        		    ,width: 300
        		},{
        		    xtype: 'textfield'
        		    ,fieldLabel: _('estates.appliances')
        		    ,name: 'appliances'
        		    ,width: 300
        		},{
        		    xtype: 'combo'
        		    ,fieldLabel: _('estates.air_conditioning')
        		    ,name: 'air_conditioning'
        		    ,width: 300
        		    ,hiddenName: 'air_conditioning'
        		    ,emptyText: 'Select air conditioning...'
        		    ,store: air_conditioning_store
        		    ,valueField: 'value'
           		    ,displayField: 'text'
        		    ,triggerAction: 'all'
        		    ,mode : 'local'
        		},{
        		   xtype: 'albums-combo-names'
        		}]
            });
            
            Estates.window.UpdateEstate.superclass.constructor.call(this,config);
        };
        Ext.extend(Estates.window.UpdateEstate,MODx.Window);
        Ext.reg('estates-window-estate-update',Estates.window.UpdateEstate);
        
        
          • 28215
          • 4,149 Posts
          Instead of:

          
          	    } else {
          		this.updateEstateWindow.setValues(this.menu.record);
          	    }
          

          Try:

          }
          this.updateEstateWindow.setValues(this.menu.record);
          


          (so that setValues always runs).
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
            • 15827
            • 3 Posts
            Thanks a million! That resolved the issue perfectly. smiley