1. #1
    Ext User
    Join Date
    Jul 2007
    Posts
    7
    Vote Rating
    0
    jthorn is on a distinguished road

      0  

    Default ComboBox posting display field not value to server

    ComboBox posting display field not value to server


    Hello,
    Can someone please help me figure out why the code below is posting the display field of a combo box to the server and not the value field?

    Thanks!

    Jeff

    Code:
                f = new Ext.form.Form({
                    labelAlign: 'right'
                });
                
                var store = new Ext.data.Store({
                    proxy: new Ext.data.HttpProxy({url: "get_types"}),
                    reader: new Ext.data.ArrayReader(
                        { id: 0 },
                        [ {name: 'id', type: 'int'}, {name: 'name'} ]
                    )
                });
                
                store.load();
                
                f.fieldset(
                    {legend: "Options"},
                    new Ext.form.ComboBox({
                        fieldLabel: 'File Type',
                        store: store,
                        emptyText:'Select a file type...',
                        width:200,
                        displayField: 'name',
                        valueField: 'id',
                        triggerAction: 'all',
                        name: 'fileType',
                        allowBlank: false
                    })
                );
                
                var submit = f.addButton({
                    text: 'Submit',
                    handler: function() {
                        f.submit({
                            url:'submit_options',
                            success: this.onSuccess,
                            failure: this.onFailure
                       });
                    }
                });
                           
                uploadDlg = new Ext.BasicDialog('uploadDlg', { 
                                        width:520,
                                        height:200,
                                        resizable: false,
                                        shadow:true,
                                        modal:true,
                                        title: 'Select Options'
                                    });
                                    
                f.render(uploadDlg.body);    
                uploadDlg.show();

  2. #2
    Sencha Premium Member Troy Wolf's Avatar
    Join Date
    May 2007
    Location
    Kansas City
    Posts
    243
    Vote Rating
    2
    Troy Wolf is on a distinguished road

      0  

    Default


    jthorn, this one was definitely not obvious to me either. Check out the hiddenName property of the ComboBox.
    http://extjs.com/deploy/ext/docs/out...fig-hiddenName

    You can change your ComboBox to the code below. Note, the only thing I added is hiddenName. I moved your name property to keep the 2 at the top together for clarity.
    Code:
    new Ext.form.ComboBox({
        name: 'XfileType',
        hiddenName: "fileType",
        fieldLabel: 'File Type',
        store: store,
        emptyText:'Select a file type...',
        width:200,
        displayField: 'name',
        valueField: 'id',
        triggerAction: 'all',
        allowBlank: false
    })
    I'm a relative Ext noob myself, so take this for what it's worth.

  3. #3
    Ext User r2k's Avatar
    Join Date
    Aug 2007
    Posts
    67
    Vote Rating
    0
    r2k is on a distinguished road

      0  

    Default


    ok, i passed for that before i tink that is the the defaul behaivor for the fields in ext forms , and the only way that i found to solve is to pass params in the form.submit that contains the respective values for the combos.

    example
    PHP Code:
    form.submit({
                       
    params: {numlineaform.findField('cveLinea').getValue(), saResp2form.findField('saResp').getValue()}}); 
    'cveLinea' and 'saResp' are combos

    i hope that this helps you to solve your problem

  4. #4
    Ext User
    Join Date
    Jul 2007
    Posts
    7
    Vote Rating
    0
    jthorn is on a distinguished road

      0  

    Default


    The hiddenName config option, as Troy suggested, solved my problem. Thanks.

    I guess I was under the impression that the field that I specify in the valueField is what would be returned to the server on a POST. I guess this is not the case?

  5. #5
    Ext User
    Join Date
    Feb 2009
    Posts
    1
    Vote Rating
    0
    sethostrich is on a distinguished road

      0  

    Default


    I ran into this as well. I just ended up setting the hiddenName = name, and it seemed to work fine.

  6. #6
    Ext User jorrill's Avatar
    Join Date
    Mar 2009
    Posts
    13
    Vote Rating
    0
    jorrill is on a distinguished road

      0  

    Default variant: initially submits display string, on change submits proper value

    variant: initially submits display string, on change submits proper value


    I'm getting different behavior with the combo box. I've got a setup where the value I want is an integer, and the human-readable display is a string. When the combobox initially draws, it is showing the "display" value, and if you click "submit" without changing anything, that string is what the server gets. However, if the user accesses the combo box and selects something, then I'm getting the integer value as expected. Here (I hope) are the relevant bits of code:

    Code:
    var BedCountSharingOption = Ext.data.Record.create([
        {name: 'bedCountSharingOptionId', mapping: 'id', type: 'int'},
        {name: 'sharingOption', mapping: 'sharingOption'},
        {name: 'sharingOptionAbbrev', mapping: 'sharingOptionAbbrev'}
    ]);
    
    var bcsReader = new Ext.data.JsonReader({
        id: 'iD'
    }, BedCountSharingOption);
    
    function getBcsStore() {
        var bcsProxy = new Ext.data.JsonRpcProxy( function(cb, query) {
            jsonrpc.lookupManager.getBedCountSharingOptions(cb) ;
            }
        ) ;
    
        var bcsStore = new Ext.data.Store({
            reader: bcsReader,
            proxy: bcsProxy,
            autoLoad: true
    
        });
    
        return bcsStore ;
    }
    
        bcsCombo = new Ext.form.ComboBox({
                            name: 'bedCountSharingOption',
                            hiddenName: 'bedCountSharingOption',
                            fieldLabel:'Share bed count with other facilities',
                            xtype: 'combo',
                            editable: false,
                            store: bcsStore,
                            triggerAction: 'all',
                            valueField: 'bedCountSharingOptionId',
                            displayField: 'sharingOption'
    
        });

  7. #7
    Sencha User
    Join Date
    Apr 2008
    Posts
    26
    Vote Rating
    0
    Drakkhen is on a distinguished road

      0  

    Default


    jorrill I have the exact prob, did you find a solution ?

  8. #8
    Ext User jorrill's Avatar
    Join Date
    Mar 2009
    Posts
    13
    Vote Rating
    0
    jorrill is on a distinguished road

      0  

    Default


    Nope, no solution yet. Nothing but crickets so far. At the moment I've put this problem aside, but if/when I find a solution I'll try to remember to post something here.

  9. #9
    Ext User
    Join Date
    Sep 2007
    Posts
    97
    Vote Rating
    0
    talshadar is on a distinguished road

      0  

    Default


    Not sure if this helps but I always put

    Code:
    emptyText:"Please Select..."
    in the config options for the combo box - that resolves that problem for me.

  10. #10
    Sencha User
    Join Date
    Apr 2008
    Posts
    26
    Vote Rating
    0
    Drakkhen is on a distinguished road

      0  

    Default


    It didn't for me.
    Still when the form is send and the user didn't use the combobox, the diplay fiel is send instead the valueField.

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