We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33969
    • 60 Posts
    I wrote a small component that inputs store locations for a manufacturer's website. The inputs all work OK - but I want to change two of the inputs from textfields to a drop downs.

    This is the grid code for the province input, and I would like to make that a select/option list:

    {
    header: _('storelocator.prov')
    ,dataIndex: 'prov'
    ,sortable: false
    ,width: 50
    ,editor: { xtype: 'textfield' }
    }

    However I don't know to make this into a select/option list?

    Any help would be appreciated.

      Michael Regan
      TIMR Web Services
      Phone: 250.218.5284
      Eamil: [email protected]
      Website: timr.ca
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      A dropdown/select/option list is called a combobox in ExtJS speak.

      Here's an example I copy/pasted from my current project:
      FrontDeskMan.combo.RoomTypes = function(config) {
          config = config || {};
          Ext.applyIf(config,{
              url: FrontDeskMan.config.connectorUrl,
              baseParams: {
                  action: 'mgr/roomtype/getcombo',
                  property: config.property,
                  emptyOption: config.emptyOption || false
              },
              fields: ['id','name'],
              hiddenName: config.name || 'roomtype',
              pageSize: 15,
              valueField: 'id',
              displayField: 'name'
          });
          FrontDeskMan.combo.RoomTypes.superclass.constructor.call(this,config);
      };
      Ext.extend(FrontDeskMan.combo.RoomTypes,MODx.combo.ComboBox);
      Ext.reg('frontdeskman-combo-roomtypes',FrontDeskMan.combo.RoomTypes);[

      (in that case use xtype: 'frontdeskman-combo-roomtypes' as your editor)

      and the processor works pretty much the same as grid processors.. ie:

      $count = $modx->getCount('fdmRoomType');
      $roomtypes = $modx->getCollection('fdmRoomType');
      
      foreach ($roomtypes as $obj) {
          /* @var fdmRoomType $obj */
          $results[] = $obj->toArray('', false, true);
      }
      
      $returnArray = array(
          'success' => true,
          'total' => $count,
          'results' => $results
      );
      return $modx->toJSON($returnArray);

      but then most likely setting the limit/start on a query and things like that.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 33969
        • 60 Posts
        Thanks Mark - that is exactly what I needed.
          Michael Regan
          TIMR Web Services
          Phone: 250.218.5284
          Eamil: [email protected]
          Website: timr.ca