1. #1
    Sencha User
    Join Date
    Mar 2013
    Posts
    10
    Vote Rating
    0
    Sinredux is on a distinguished road

      0  

    Default Having problems sending the right value from my ComboBox

    Having problems sending the right value from my ComboBox


    Hey, I'm having troubles sending the right value by using a ComboBox. The value that's being sent, is the displayField instead of my valueField. I've no idea what I'm doing wrong, so maybe someone could lead me into the right direction..

    Code:
    // Using below command in my console shows the 'lease_soort' value as my ComboBox value
    Ext.getCmp("pnlLease");
    // value: 'Eigen auto'
    // valueField: 'id'
    The ComboBox
    Code:
    new Ext.form.ComboBox(            
    {                    
        fieldLabel: 'Soort Lease',
        hiddenName: 'lease_soort',
        store: dsGetLease,
        valueField: 'id',
        displayField: 'lease_soort',
        editable: false,
        mode: 'local',
        triggerAction: 'all',                    
        id: 'pnlLease',
        emptyText: 'Selecteer...',                    
        width: 145,
        listWidth: 145,
        allowBlank: false                    
    })
    The store I'm using
    Code:
    // The array from my proxy: [{"id":"1","lease_soort":"Eigen auto"},{"id":"2","lease_soort":"Korte Lease"},
    //{"id":"3","lease_soort":"Lange Lease"}]
    var dsGetLease = new Ext.data.Store(
    {
        proxy: new Ext.data.HttpProxy(
        {
            url: './data/modules/carpark.php?sort=carpark&action=get-lease'
        }),
        remoteSort: true,
        autoLoad: true,
        reader: new Ext.data.JsonReader(
        {
            id: 'id'
        },
        [
            {name: 'id'},
            {name: 'lease_soort'}
            
        ])
    });
    Everything works visual.. Why doesn't it return the 'id' as my ComboBox value?

    The ComboBox below does​ send the valueField instead of the displayField..
    Code:
    new Ext.form.ComboBox(
    {
        fieldLabel: 'Winterbanden',
        hiddenName: 'winterbanden',
        valueField: 'id',
        displayField: 'winterbanden',
        store: new Ext.data.ArrayStore(
        {
            fields:['id', 'winterbanden'],
            data :[['1', 'Ja'],
                   ['0', 'Nee']]
        }),
        disabled: false,
        editable: false,
        mode: 'local',
        triggerAction: 'all',
        id: 'pnlWinterbanden',
        emptyText: 'Selecteer...',
        width: 145,
        listWidth: 145,
        allowBlank: false
    })

  2. #2
    Sencha User
    Join Date
    Mar 2013
    Posts
    10
    Vote Rating
    0
    Sinredux is on a distinguished road

      0  

    Default Encountered the cause of my problem

    Encountered the cause of my problem


    Okay, after testing some more I've encountered the cause of my problem.

    I've got a gridPanel with a rowselect event, basically when I click on a row it loads the row records into my form. When I change one of the ComboBox selections and submit my form again, it does send the id's instead of the displayField values. Which means the values get replaced with the values from the gridPanel store.

    Does someone happen to know how to prevent those ComboBoxes to change their valueField into the row records?

    Code:
    // row select event in my gridPanel.
    sm: new Ext.grid.RowSelectionModel(
    {
        singleSelect: true,
        listeners: {
            rowselect: function(sm, row, rec) 
            {
                Ext.getCmp("company-form").getForm().loadRecord(rec);
    
    
                var automerkID = rec.data.merkid;
    
    
                dsGetModel.proxy.setUrl('./data/modules/carpark.php?sort=carpark&action=get-model&automerkid='+automerkID, true);
                dsGetModel.load();
            }
        }
    })

  3. #3
    Sencha User
    Join Date
    Mar 2013
    Posts
    10
    Vote Rating
    0
    Sinredux is on a distinguished road

      0  

    Default


    Never mind, I fixed my problem by sending the ID's in my store aswell, and using those values as my hiddenName.