PDA

View Full Version : Having problems sending the right value from my ComboBox



Sinredux
19 Mar 2013, 6:01 AM
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..



// 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

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


// 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..


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
})

Sinredux
19 Mar 2013, 7:34 AM
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?



// 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();
}
}
})

Sinredux
20 Mar 2013, 1:44 AM
Never mind, I fixed my problem by sending the ID's in my store aswell, and using those values as my hiddenName.