Amor.o
Amor.o

Reputation: 540

select field in extjs

i'am using extjs 6.5.3 trial version and i want to make a select field but it doesn't work my code is like this ( toolbar with buttons and the select field)

                        {
                          xtype : 'button',
                          text  : 'Next',
                          iconCls : 'x-fa fa-arrow-circle-right',
                          handler : function () {
                              Ext.getCmp('employeescheduler').shiftNext();
                          }
                      },{
                           xtype: 'selectfield',
                           label: 'Choose one',
                           options: [{
                                text: 'First Option',
                                value: 'first'
                            }]
                      }

but it show me an error :

Error: [Ext.create] Unrecognized class name / alias: widget.selectfield

i tried to require it but without result

requires : [
    'Sch.examples.externaldragdrop.view.MainView',
    'Ext.field.Select'
],

Upvotes: 2

Views: 3654

Answers (2)

Tyr
Tyr

Reputation: 2810

You have to bind a store to the combobox:

Fiddle: https://fiddle.sencha.com/#view/editor&fiddle/2es4

        Ext.create('Ext.form.field.ComboBox', {
           renderTo: Ext.getBody(),
           fieldLabel: 'Select an option',
           store: Ext.create('Ext.data.Store', {
               fields: ['optionName', 'value'],
               data: [
                    {
                        value: 1,
                        optionName: 'First Option'
                    },
                    {
                        value: 2,
                        optionName: 'Second Option'
                    },
                    {
                        value: 3,
                        optionName: 'Third Option'
                    }
                ]
           }),
           emptyText: 'Select...',
           displayField: 'optionName',
           valueField: 'value'
        });

Upvotes: 2

ololoken
ololoken

Reputation: 58

extjs uses combobox, combo xtypes for selectboxes, so just use

      {
                       xtype: 'combo',
                       label: 'Choose one',
                       options: [{
                            text: 'First Option',
                            value: 'first'
                       }]
      }

Upvotes: 0

Related Questions