PDA

View Full Version : Combobox selections



brunowerneck
13 Sep 2010, 4:50 PM
I have been searching this forum extensively but couldn't find a viable solution to my problem. Maybe I'm using the wrong query. Anyway, I'm stuck.

Picture this scenario (data is fictional, problem is not):



var test = [
[1,'Ana','Smith'],
[2,'Ana','Goldman'],
[3,'Ana','McDonald']
];

var store = new Ext.data.ArrayStore({
fields:['id','fname','lname'],
data:test
});
var formP = new Ext.FormPanel({
id:'loginPanel',
frame:true,
items:[{
xtype:'combo',
store:store,
mode:'local',
displayField:'fname',
valueField:'id',
hiddenValue:'id',
hiddenName:'idUser',
}],
buttons:[{
text:'Enviar',
listeners:{
click:function(){
formP.getForm().submit({
url:'lib/php/checkLogin.php',
success:function(){
//
}
});
}
}
}]
});


Here's the problem, it doesn't matter which "Ana" I select, it always sends the first one. This is driving me nuts. Help anyone?

vishalnnsingh
13 Sep 2010, 11:48 PM
I tried to solve the problem but stuck too, never thot of it, i know in the real world it doesn't make sense using the same displayfield with different id unless you give a distinguing para in the display field, but still, now m thinking that is it the displayfield that the combobox uses to fetch the id from the store, because changing the diplayfield in the store i.e fname to three different values itself is solving the problem.

Condor
14 Sep 2010, 12:00 AM
This is a know bug (fix here (http://www.sencha.com/forum/showthread.php?101123-OPEN-1033-ComboBox-reports-incorrect-value-when-non-unique-display-fields-are-used&p=475694#post475694)).

vishalnnsingh
14 Sep 2010, 12:12 AM
Thanx Condor...

brunowerneck
14 Sep 2010, 3:33 AM
@vishalnnsingh

It does make sense in the real world. Actually, it was generated because I had to implement exactly this situation and had to use a workaround. My real data is client_ID, client_Name, client_SerialNumber. Id and Serial Number are unique but the person who is going to select it cannot have access to ID or SN data, just the name and the same cliente name may have more than one serial number so that it does repeat the name.

@Condor, thank you. I'll try the fix when I get home and reply back.

vishalnnsingh
14 Sep 2010, 3:49 AM
But how will you distinguish one ana from another ana, what if i want to debit 500$ to ana with serial no 567980, there must be someway for the user to know about which ana he/ she is chosing.
Anyways maybe i am not looking at things from your point of view.
I apologise if i am being a nuisance :)

Condor
14 Sep 2010, 3:55 AM
There is indeed a problem if you make the combobox editable:true and start typing the name 'Ana'. In that case it will use the first 'Ana' from the list.

The patch does however solve the problem when selecting the second 'Ana' from the list.

brunowerneck
14 Sep 2010, 12:04 PM
No apology is necessary, vishalnnsingh. Your questioning is quite valid. Perhaps, if all of us explained our problems in detail, it would be easier to understand our scenario and deal with the problems more efficiently. ;)

In my case, the combobox has a suggest feature and the list of items loads asynchronously with a Ext.XTemplate, allowing the user to see data other than the cliente name. From these other data, she will choose the correct one.

vishalnnsingh
14 Sep 2010, 8:43 PM
Got you, thank you condor and brunowerneck :)