We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Alright, I know I'm just missing something but I'm not able to get the values from a field stored via SuperBoxSelector combo type. The form works and stores the data as a comma list, but will not pre-select the items when reloaded.

    The JS that used to create the SuperBoxSelector for users
    MODx.combo.Users = function (config) {
        config = config || {};
        Ext.applyIf(config, {
        	xtype:'superboxselect'
            ,triggerAction: 'all'
    	,mode: 'remote'
            ,valueField: "id"
            ,displayField: "username"
    	,store: new Ext.data.JsonStore({
    		id:'id',
    		autoLoad: true,
    		root:'results',
    		fields: ['username', 'id'],
    		url: MODx.config.connectors_url+'security/user.php',
    		baseParams:{
    			action: 'getList'
    			//,usergroup: 2
    		}
    	})
        });
        MODx.combo.Users.superclass.constructor.call(this, config);
    };
    Ext.extend(MODx.combo.Users, Ext.ux.form.SuperBoxSelect);
    Ext.reg('modx-superbox-user', MODx.combo.Users );
    


    Code for the processor storing the values:
    $this->setProperty('owners', implode(',', $_REQUEST['owners'] ));


    JS for form field rendering:
            {
                xtype: 'modx-superbox-user'
                ,fieldLabel: _('contactmanagercenter.label_owners')
                ,name: 'owners[]'
                ,anchor: '100%'
                ,id: 'owners'
            }


    Cheers [ed. note: charless last edited this post 11 years, 5 months ago.]
      Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
      Visit CharlesMx.com for latest news and status updates.
      • 33968
      • 863 Posts
      What does your getlist processor look like?

      As you are imploding the 'owners' array when storing in the database, I guess you'll need to explode it back into an array when sending it back to the client.
      • It's just sending back raw data, no manipulation on the dataset. I thought that the superbox used a string with comma separation, totally could be getting that mixed up. The other thing I had seen was reference to using a panel listener that would set the values, not sure about that either.
          Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
          Visit CharlesMx.com for latest news and status updates.
          • 4172
          • 5,888 Posts
          still the easiest way to get this work is to use MIGXdb and a selectboxmultiple - TV-type.

          But needed this today for a custom-made-CMP and could get this work so far with this code:

          bdListings.combo.Category = function (config) {
              config = config || {};
          Ext.applyIf(config, {
              xtype:'superboxselect'
              ,triggerAction: 'all'
              ,extraItemCls: 'x-tag'
              ,mode: 'remote'
              ,width: 350
              ,fields: ['id','name']
              ,displayField: 'name'
              ,valueField: 'id'
              ,store: new Ext.data.JsonStore({
                  id:'id',
                  autoLoad: true,
                  root:'results',
                  fields: ['name', 'id', 'is_parent'],
                  remoteSort: true,
                  url: bdListings.config.connector_url,
                  baseParams:{
                      action: 'mgr/category/getcombo'
                  }
                  ,listeners: {
                  'load': {fn:function(store, records, options ) {
                      this.hiddenName = 'categorylist[]';
                      //this.setWidth('350');
                  }
                  },scope : this
              }   
              })
              ,listeners: {
                  'beforeselect': {fn:function(combo, record, index ) {
                      if (record.data.is_parent == '1'){
                          return false;
                      }
                  }
                  },scope : this
                   
              }   
              });
              bdListings.combo.Category.superclass.constructor.call(this, config);
              this.store.load();
          };
          Ext.extend(bdListings.combo.Category, Ext.ux.form.SuperBoxSelect);
          Ext.reg('bdlisting-combo-category', bdListings.combo.Category);
          


          in window-form-items I have:

          {
                              name: 'categorylist',
                              hiddenName: 'categorylist',
                              fieldLabel: _('bdlistings.category')+'*',
                              xtype: 'bdlisting-combo-category',
                              allowNegative: false,
                              anchor: '0 0',
                              allowBlank: false,
                              id: 'bdl-win-'+config.id+'-category'
                          }


          the only issue, I have now, is the witdth of the superboxselect.
          Most times the width is ok, but sometimes the width of the whole thing gets very small.
          Anybody has an Idea for an possible fix?


          [Edit]
          when resizing the window, the superboxselect gets back to its normal size. [ed. note: Bruno17 last edited this post 11 years, 5 months ago.]
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 4172
            • 5,888 Posts
            seems I could fix the superboxselect-size-issue for my situation by overwriting the onResize - function with an empty function:

            Ext.extend(bdListings.combo.Category, Ext.ux.form.SuperBoxSelect,{
                    onResize: function(w, h, rw, rh) {
                            /*
                            var reduce = Ext.isIE6 ? 4 : Ext.isIE7 ? 1 : Ext.isIE8 ? 1 : 0;
                            if (this.wrapEl) {
                                    this._width = w;
                                    this.outerWrapEl.setWidth(w - reduce);
                                    if (this.renderFieldBtns) {
                                            reduce += (this.buttonWrap.getWidth() + 20);
                                            this.wrapEl.setWidth(w - reduce)
                                    }
                            }
                            
                            Ext.ux.form.SuperBoxSelect.superclass.onResize.call(this, w, h, rw, rh);
                            this.autoSize();
                            */
                    }    
            });
            
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 38878
              • 255 Posts
              Bruno,

              Are populating this form control with any values in a update form? Tats where I'm stuck.

              Thx

              Quote from: Bruno17 at Nov 13, 2012, 08:43 PM
              seems I could fix the superboxselect-size-issue for my situation by overwriting the onResize - function with an empty function:

              Ext.extend(bdListings.combo.Category, Ext.ux.form.SuperBoxSelect,{
                      onResize: function(w, h, rw, rh) {
                              /*
                              var reduce = Ext.isIE6 ? 4 : Ext.isIE7 ? 1 : Ext.isIE8 ? 1 : 0;
                              if (this.wrapEl) {
                                      this._width = w;
                                      this.outerWrapEl.setWidth(w - reduce);
                                      if (this.renderFieldBtns) {
                                              reduce += (this.buttonWrap.getWidth() + 20);
                                              this.wrapEl.setWidth(w - reduce)
                                      }
                              }
                              
                              Ext.ux.form.SuperBoxSelect.superclass.onResize.call(this, w, h, rw, rh);
                              this.autoSize();
                              */
                      }    
              });