Jez D
Jez D

Reputation: 1489

Sencha Touch: How to refresh selectfield after store update

I am trying to get a Sench selectfield to update dynamically.

Here is the code for the selectfield

items: [
        {
             xtype : 'container',
             flex: 1,
             id: 'introtext',
             html: '<p>Welcome your items above</p>'
        },
        {
             xtype : 'selectfield',
             store : companiesStore2,
             name : 'companies',
             id : 'companiesSelect',
                itemId: 'companySelect',
                valueField : 'companyname',
                displayField : 'companyname',
                style: 'overflow:hidden',
                listeners: {
                    change: function(field,value) {
                        getStats(value)
                    }
                }   
          },.......

When the page loads, the store has only one value. After login, more values are added to the store. console.log(companiesStore2) confirms that the new values are indeed being added to the store. However, they are not showing in my select field.

I have tried companiesStore2.refresh() but error message says the object has no method refresh.

Using sencha touch 2.3

Upvotes: 0

Views: 905

Answers (2)

Jez D
Jez D

Reputation: 1489

I have come upon an answer that seems to work for me. After the data has changed, I re-assign the store to the selectfield using:

Ext.getCmp('companiesSelect').setStore(companiesStore2)

This seems to solve the problem that I was having.

Upvotes: 0

jenson-button-event
jenson-button-event

Reputation: 18951

You have not posted any code to show how the store gets its new data.

2 things to try:

  1. make the combo's queryMode: 'local'

  2. when the store changes (add a listener e.g. companiesStore2.on('datachanged', ...)?), do this: comboBox.bindStore(companiesStore2)

Upvotes: 1

Related Questions