Results 1 to 8 of 8

Thread: Combobox problem with getValues() and getValue() !!!

  1. #1
    Ext User ritesh.kapse's Avatar
    Join Date
    May 2008
    Location
    Pune, India
    Posts
    120
    Vote Rating
    0
      0  

    Post [Solved]Combobox problem with getValues() and getValue() !!!

    Hi All,

    I have got a form where user can dynamically add combo boxes. At such I want to use Ext.getCmp('').getForm().getValues() for getting the combo box values.

    But when I use Ext.getCmp('panel1').getForm().getValues() its returning me the displayField value. If I use Ext.getCmp('cmb1').getValue() in firebug for each combo box component it gives me the required valueField value.

    Is there any easy solution to this ?

    I want to use getValues() hear...

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Redwood City
    Posts
    30,854
    Vote Rating
    87
      0  

    Default

    I have a Feature Request outstanding which I think should handle this: http://extjs.com/forum/showthread.php?t=41093

    The code is untested, but I think the principle is correct.
    Longtime Sencha engineer. Now surplus to requirements apparently...

  3. #3
    Ext User ritesh.kapse's Avatar
    Join Date
    May 2008
    Location
    Pune, India
    Posts
    120
    Vote Rating
    0
      0  

    Post

    Thanks Animal...

    I wish this issue gets solved in future release...

    But for now I have made use of hidden form fields. I set the values in corresponding hidden fields on 'change' event of each combo box.

    Hope this helps someone else..

  4. #4
    Ext JS Premium Member
    Join Date
    Sep 2009
    Posts
    59
    Vote Rating
    2
      0  

    Default Same issue in Extjs 3.0.3

    I have the same issue as you for Extjs version 3.0.3. When trying to get the values of a form via getValues, I get the displayField for comboboxes instead of the valueField. I got around the issue by not using the getValues method at all. I instead just iterated through each field of my form and manually called the getValue method on each field.

  5. #5
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Redwood City
    Posts
    30,854
    Vote Rating
    87
      0  

    Default

    Quote Originally Posted by wsi View Post
    I have the same issue as you for Extjs version 3.0.3. When trying to get the values of a form via getValues, I get the displayField for comboboxes instead of the valueField. I got around the issue by not using the getValues method at all. I instead just iterated through each field of my form and manually called the getValue method on each field.
    hiddenName?
    Longtime Sencha engineer. Now surplus to requirements apparently...

  6. #6
    Ext JS Premium Member
    Join Date
    Sep 2009
    Posts
    59
    Vote Rating
    2
      0  

    Default

    I don't believe I have a hidden name. To give you a better picture of the issue, I am using a wizard component supplied by http://www.siteartwork.de/wizardcomponent/. The wizard has a method called getWizardData which iterates through all the forms in the container and returns an array of all the values of every field in the wizard. The original implementation uses getValues on each of the form that exist in the wizard. As mentioned before, getValues returns the display value of combo boxes instead of the value value. Below is the code with my modification to fix the combo boxes issue.

    Code:
    /**
         * Returns the form-data of all cards in this wizard. The first index is the
         * id of the card in this wizard,
         * and the values are objects containing key/value pairs in the form of
         * fieldName : fieldValue.
         *
         * @return {Array}
         */
        getWizardData : function()
        {
            var formValues = {};
            var cards = this.cards;
            for (var i = 0, len = cards.length; i < len; i++) {
                if (cards[i].form) {
                    // Do not use getValues as it returns the wrong value from choices
                    // known bug issue with Extjs 3.0
                    // formValues[cards[i].id] = cards[i].form.getValues(false);
                    formValues[cards[i].id] = {};
                    var formItems = cards[i].form.items;
                    for(var j = 0, lenj = formItems.getCount(); j < lenj; j++)
                    {
                        formValues[cards[i].id][formItems.itemAt(j).getName()] = formItems.itemAt(j).getValue();
                    }
                    
                } else {
                    formValues[cards[i].id] = {};
                }
            }
    
            return formValues;
        },

  7. #7
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Redwood City
    Posts
    30,854
    Vote Rating
    87
      0  

    Default

    Yes. Because you need to use hiddenName. Read the API docs on it.
    Longtime Sencha engineer. Now surplus to requirements apparently...

  8. #8
    Ext JS Premium Member
    Join Date
    Aug 2010
    Posts
    18
    Vote Rating
    0
      0  

    Default Passing in a selection from previous LOVcombo

    I am having trouble passing in the variable from my SQL statement into the store. I am trying to make the available selection(s) on one LOVcombo box dependent on the other previous selections the user has made. here is my code


    var programStore = new Ext.data.Store({
    url: '$self?get_program=yes',
    reader: new Ext.data.JsonReader({
    fields: ['id', 'program_group', 'project_name'],
    root: 'rows',
    id:'id'
    })
    });

    programStore.load();

    var projectStore = new Ext.data.Store({
    url: '$self?get_project=yes',
    reader: new Ext.data.JsonReader({
    fields: ['id', 'program_group', 'project_name'],
    root: 'rows',
    id:'id'
    })
    });


    var programFilterBox = new Ext.ux.form.LovCombo({
    id : 'programFilterBox',
    anchor: '95%',
    hideOnSelect : false,
    fieldLabel: 'Program',
    store : programStore,
    triggerAction : 'all',
    displayField:'program_group',
    valueField: 'program_group',
    mode : 'local',
    listeners:{
    'select': sayHi
    }
    });

    function sayHi(){

    var selection = programFilterBox.getValue()
    //Ext.Msg.alert(selection);
    Ext.Ajax.request({
    url: '$self',
    method: 'POST',
    params: {get_project:'yes', program_selected: selection},// program_selected is the variable in my SQl statement where clause
    success: function(response){
    projectStore.load();
    },
    failure: function(response){
    Ext.Msg.alert('No did not work');
    }
    });
    }

    var projectFilterBox = new Ext.ux.form.LovCombo({
    id : 'projectFilterBox',
    anchor: '95%',
    hideOnSelect : false,
    fieldLabel: 'Project',
    store : projectStore,
    triggerAction : 'all',
    displayField:'project_name',
    valueField: 'project_name',
    mode : 'local'
    });

Posting Permissions

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