1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    46
    Vote Rating
    0
    eaglefox12 is on a distinguished road

      0  

    Default Unanswered: setValue of a combobox with valueField

    Unanswered: setValue of a combobox with valueField


    This is my model for my combo

    Code:
    Ext.define('ExtJS.myApp.ComboModel', {
        extend: 'Ext.data.Model',
        alias: 'widget.combomodel',
        fields: [
            { name: 'ID', type: 'int' },
            { name: 'title', type: 'string' }
         ]
    });
    This is comboStore
    Code:
    this.comboStore = Ext.create('Ext.data.Store', {
                model: 'ExtJS.myApp.ComboModel',
                autoLoad: true,
                scope: this,
                proxy: {
                    type: 'ajax',
                    scope: this,
                    url: 'myApp/GetRecords',
                    reader: {
                        type: 'json',
                        root: 'data'
                    }
                }
            });
    Code:
    this.myComboBox = Ext.create('Ext.form.ComboBox', {
                store: this.comboStore,
                queryMode: 'local',
                displayField: 'title',
                valueField: 'ID'
            });
    This is the json object I get for my store:
    Code:
    {"ID":"111","title":"Ext Page 1"}
    now when I try to set the value of the combobox like this.
    Code:
    this.myComboBox.setValue('111');
    the combobox shows "111" instead of "Ext Page 1"

    What would I have to do so that the combobox displays displayField while setting valueField

  2. #2
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,337
    Answers
    101
    Vote Rating
    75
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Are you setting the value *before* the store loads? this problem is an indication that you probably are.

  3. #3
    Sencha User
    Join Date
    Jun 2012
    Location
    India
    Posts
    48
    Answers
    4
    Vote Rating
    3
    girish.arjunagi is on a distinguished road

      0  

    Default


    Why don't you use this.myComboBox.select('111') function of combo.

  4. #4
    Sencha User
    Join Date
    Sep 2012
    Posts
    46
    Vote Rating
    0
    eaglefox12 is on a distinguished road

      0  

    Default


    Girish... thanks for your answer... I tried using select. It show up as '111' on the combobox. I actually want to show 'Ext Page 1'. And then when I try to save the value of the combobox. I want to save '111'. but either doing getRawValue or getValue gives me the displayField.
    Quote Originally Posted by girish.arjunagi View Post
    Why don't you use this.myComboBox.select('111') function of combo.

  5. #5
    Sencha User
    Join Date
    Sep 2012
    Posts
    46
    Vote Rating
    0
    eaglefox12 is on a distinguished road

      0  

    Default


    Hi Jay... I tried setting the value after loading the store too, but get the same result. However, when I select a different item from the dropdown, I get the id numbers. It's not giving the right value only when I am trying to set a default value.

    Quote Originally Posted by jay@moduscreate.com View Post
    Are you setting the value *before* the store loads? this problem is an indication that you probably are.

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar