1. #1
    Sencha User
    Join Date
    Nov 2010
    Posts
    48
    Vote Rating
    0
    nil5286 is on a distinguished road

      0  

    Default Answered: Load the Combobox with the Json File

    Answered: Load the Combobox with the Json File


    Hi,

    I've a problem loading combobox from a Json file Below is the exception i get

    uncaught exception: Either a valid store, or a HTML select to transform, must be configured on the combo.

    Code:
            Ext.define('FieldsetDynamicControls', {
                extend: 'Ext.data.Model'
        , fields: ['name', 'label', 'config']
            });
    
    
            var userStore;
            Ext.require('Ext.data.Store');
            Ext.onReady(function () {
    
    
                Ext.create('Ext.form.field.ComboBox', {
                    fieldLabel: 'Select a single state',
                    renderTo: Ext.getBody(),
                    displayField: 'name',
                    valueField: 'label',
                    width: 320,
                    labelWidth: 130,
                    store: userStore,
                    queryMode: 'local',
                    typeAhead: true
                });
    
    
                userStore = Ext.create('Ext.data.Store', {
                    model: 'FieldsetDynamicControls',
                    autoLoad: true,
                    proxy: {
                        type: 'ajax',
                        //the store will get the content from the .json file
                        url: '/controllist.json',
                        reader: {
                            type: 'json',
                            root: 'list'
                        },
                        writer: {
                            type: 'json'
                        }
                    }
    
    
                });
            });

    My Json file is as below:

    Code:
    {list:[
        { label: 'Display Name', name: 'displayName' }
        , { label: 'First Name', name: 'givenName' }
        , { label: 'Middle Name', name: 'initials' }
        , { label: 'Last Name', name: 'sn' }
        , { 
            label: 'Checkbox'
            , name: 'checkbox'
            , config: { xtype: 'checkbox' }
        }
        , { 
            label: 'Combo'
            , name: 'combo'
            , config: { xtype: 'combo' }
        }
        , { 
            label: 'Number'
            , name: 'number'
            , config: { xtype: 'numberfield' }
        }
        , { 
            label: 'Date'
            , name: 'date'
            , config: { xtype: 'datefield' }
        }
    ]
    }

    Any help is appreciated. I am using
    extjs 4.0.2a.

    Thanks

  2. you should create the store before you create the combobox. userStore is undefined when you use it in creating the combobox.

  3. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,099
    Vote Rating
    96
    Answers
    113
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      0  

    Default


    you should create the store before you create the combobox. userStore is undefined when you use it in creating the combobox.

  4. #3
    Sencha User
    Join Date
    Nov 2010
    Posts
    48
    Vote Rating
    0
    nil5286 is on a distinguished road

      0  

    Default


    Thanx very much , ya i just realized that and it fixed my problem.

Thread Participants: 1

Tags for this Thread