Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filling Extjs Combobox with static data

Tags:

extjs

extjs4

I have in my base class a combobox, where I only configure the "fields" property. Like this:

items: [
      comboText = Ext.create('Ext.form.ComboBox', {
                width: 150,
                padding: '0 20 0 0',
                displayField: 'label',
                store: Ext.create('Ext.data.Store', {
                    fields: [
                        {type: 'string', name: 'label'},
                        {type: 'string', name: 'fieldName'}
                    ]
                })
            }),
...]

How can I pass only the data property to this combo ? I tried the code below but does not work:

comboTest.store.loadData(value);

where value contains an array like this:

 [
    {"label":"First name", "fieldName":"firstname"},
    {"label":"Birth date", "fieldName":"birthdate"}
 ]

No errors, but the combobox opens nothing.

like image 327
Beetlejuice Avatar asked Oct 30 '12 15:10

Beetlejuice


1 Answers

I got this to work using:

   xtype:'combo',
   fieldLabel:'Division',
   name:'division',
   valueField: 'division',
   queryMode:'local',
   store:['A','B','C'],
   displayField:'division',
   autoSelect:true,
   forceSelection:true

I know this question is really old, but just in case anyone comes looking for an answer that works out of the box; for me this was it.

like image 61
Luis Avatar answered Oct 03 '22 23:10

Luis