Results 1 to 7 of 7

Thread: [Resolved]Combobox value is not displayed on form load

  1. #1

    Default [Resolved]Combobox value is not displayed on form load

    Hi ,
    When a form is loaded , the value of the combobox is not displayed.
    Here is the code of the combobox store:

    Code:
    Ext.define('Language_Combo', {
                extend : 'Ext.data.Model',
                
                fields : [{
                            name : 'id',
                            type : 'int'
                        }, {
                            name : 'name',
                            type : 'string'
                        }]
            });
    
    languages2_combo_store = new Ext.data.Store({ 
                model : 'Language_Combo',
                autoLoad: true,
                proxy : {
                    type : 'ajax',
                    url : 'languages.php',
                    reader : {
                        type : 'json',
                        root : 'data'
                    }
    
    
                }
            });
    Here is the combo:
    Code:
    {
    
    
                                xtype : 'combo',
                                fieldLabel : 'Language',
                                name : 'language2',
                                queryMode:'local',
                                displayField : 'name',
                                valueField:'id',
                                
                                anchor : '50%',
                                store:languages2_combo_store,
                                allowBlank: false
                                
                            }
    and here is the loading of the form:

    languages2_combo_store.load();
    edit_account_form.load();


    So the store is loaded before the form , but in the combo no value appears selected even though the combo has a list of languages loaded.

    can anyone help me?

    Thank you in advance,
    Ana
    Last edited by hendricd; 12 Jan 2012 at 7:16 AM. Reason: [/code] tags please !

  2. #2
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Default

    @ana --

    Your store is already set for autoLoad. If your intent is to load the store again, you must remember Ajax requests are asynchronous by default, so must wait for the response before a valueField match will work.

    Examine the Store.load method docs for more on the callback functions.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  3. #3

    Default

    Can you please give an example on how to load the form after the store is loaded. In Firebug, the order is first the store and then the form .
    thank you,
    Ana

  4. #4
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Default

    Quote Originally Posted by ana.cristina.ionescu View Post
    Can you please give an example on how to load the form after the store is loaded. In Firebug, the order is first the store and then the form .
    thank you,
    Ana
    Code:
    store.load({   
          callback: function(records, operation, success) {         
              if(success) {
                 edit_account_form.load();
              }
         } 
    });
    You will also need to ensure your form load response has the field language2 whose value matches one of the id's (valueField) in the language store.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  5. #5

    Default

    Still not working ! Maybe there is another issue...
    Here is the combo store response: {"data":[{"0":"1","id":"1","1":"English","name":"English"},{"0":"2","id":"2","1":"Romanian","name":"Romanian"}]}

    And here is the form loading response:


    {"success":true,"data":{"0":"11","account_number":"11","1":"688598347","pin":"688598347","2":"1","status":"1","3":"2","balance":"2","4":"1","language2":"1","5":"1","currency":"1"}}

    Everything works fine if instead of the remote store I use a simple store like:

    language_store=new Ext.data.SimpleStore({
    fields: ['id', 'name'],
    data: [['1', 'English'], ['2', 'Romanian']]
    });

    Please help, I am trying to find the issue here for more than 1 day.
    Thank you,
    Ana

  6. #6
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Default

    Ana,

    Your languages response is serialized oddly, but there are still valid values to work with -- except the type of the 'id' field should be a 'string', not 'int' (as you've defined it on the Model).

    Make sure everything matches.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  7. #7

    Default

    The type issue was the problem. Thank you!!!!!
    Next time I will try to pay more attention.
    Thanks a lot for your fasts answers.

    Ana

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •