1. #1
    Sencha User
    Join Date
    Mar 2008
    Posts
    55
    Vote Rating
    8
    andong is on a distinguished road

      0  

    Default [4.1.1 RC1] Combo field was not selected with form.loadRecord() method

    [4.1.1 RC1] Combo field was not selected with form.loadRecord() method


    Here is the combo field:

    Code:
    {
        fieldLabel: 'Gender',
        xtype: 'combo',
        name: 'gender',
        allowBlank: false,
        valueField: 'id',
        displayField: 'value',
        editable: false,
        queryMode: 'local',
        triggerAction: 'all',
        store: Ext.create('Ext.data.ArrayStore', {
            fields: ['id', 'value'],
            data: [['1', 'Male'], ['2', 'Female']]
        }),
        value: '1'
    }
    At the first time, I will open a window to show the add form and the combo correctly selects the Male option by configuration. But when I open edit window and use the form.loadRecord() method to populate the form's fields, all are populated correctly except the combo fields, all the combo fields's text are the id value (For Gender field is 1) and not select the wanted one.

    I also try to use this code to force select the option but failed
    Code:
    form.findField('gender').setValue(user.get('gender'));
    Any suggestions?
    Last edited by skirtle; 25 May 2012 at 1:47 AM. Reason: Edit to make code readable

  2. #2
    Sencha User
    Join Date
    Mar 2008
    Posts
    55
    Vote Rating
    8
    andong is on a distinguished road

      0  

    Default


    Anybody here?

  3. #3
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,575
    Vote Rating
    311
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    I suspect it's a type mismatch.

    This works as expected:

    Code:
    combo.setValue('2');
    This works the way you describe:

    Code:
    combo.setValue(2);
    It's the same against 4.1.0.

  4. #4
    Sencha User
    Join Date
    Mar 2008
    Posts
    55
    Vote Rating
    8
    andong is on a distinguished road

      0  

    Default


    Quote Originally Posted by skirtle View Post
    I suspect it's a type mismatch.

    This works as expected:

    Code:
    combo.setValue('2');
    This works the way you describe:

    Code:
    combo.setValue(2);
    It's the same against 4.1.0.
    Thanks.
    Yes, it's a data format issue - the value is int in the model. I changed the codes like below and it works

    Code:
    {
        fieldLabel: 'Gender',
        xtype: 'combo',
        name: 'gender',
        allowBlank: false,
        valueField: 'id',
        displayField: 'value',
        editable: false,
        queryMode: 'local',
        triggerAction: 'all',
        store: Ext.create('Ext.data.ArrayStore', {
            fields: ['id', 'value'],
            data: [[1, 'Male'], [2, 'Female']]
        }),
        value: 1
    }

  5. #5
    Sencha User
    Join Date
    Mar 2008
    Posts
    55
    Vote Rating
    8
    andong is on a distinguished road

      0  

    Default


    BTW, It won't need to call setValue method, just call form.loadRecord method is enough.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi