stuckedunderflow
stuckedunderflow

Reputation: 3767

Sencha Touch Combo Box using Model and Store

I have this on model

Ext.define('MyApp.model.job', {
extend: 'Ext.data.Model',
alias: 'model.job',

config: {
    fields: [{
        name: 'name',
        type: 'string'
    }, {
        name: 'value',
        type: 'string'
    }]
}

});

And this on store

Ext.define('MyApp.store.job', {
extend: 'Ext.data.Store',
alias: 'store.job',

requires: [
    'MyApp.model.job'
],

config: {
    autoLoad: true,

    data: [
    {
        name: '--Please Select--',
        value: ''
    }, {
        name: 'Job 1',
        value: 'Job1'
    }, {
        name: 'Job 2',
        value: 'Job2'
    }, {
        name: 'Job 3',
        value: 'Job3'
    }
    ],

    model: 'MyApp.model.job',
    storeId: 'jobStore'
}

});

And this is the View

                    {
                    xtype         : 'selectfield',
                    name          : 'job',
                    label         : 'Job',
                    displayField : 'name',
                    valueField : 'value',
                    store: 'jobStore'
                }   

But I got the following error on Console "Uncaught TypeError: Cannot call method 'on' of undefined"

Can someone help me?

Upvotes: 0

Views: 544

Answers (1)

Anand Gupta
Anand Gupta

Reputation: 5700

In the job store, remove the unneccessary line storeId: 'jobStore' and in the view edit store to store: 'job' and your code will be working fine. Beside this, i would ask you to remove few line of code from your snippet(Because in standard Sencha coding, we follow certain rules).

  1. requires: [ 'MyApp.model.job' ],

  2. alias: 'store.job'

  3. alias: 'model.job'

Happy coding. :)

EDIT

In app.js of your application, you should write

models: ['job'],

stores: ['job']

instead model and store.

Upvotes: 1

Related Questions