PDA

View Full Version : Incorrect Value of the combobox



mgoncharov
30 Nov 2009, 11:11 AM
I have the combobox, which works properly but sends incorrect value after the form submit.

Here's how the combo is defined:

new Ext.form.ComboBox({
name: 'customerNumber',
fieldLabel: 'Customer Number *',
store: Ext.arrow.customerNumberDS,
displayField:'na',
valueField: 'nu',
minChars : 4,
typeAhead: true,
mode: 'remote',
queryParam: 'query',
hideTrigger: true,
selectOnFocus:true,
triggerAction: 'all',
width: 250

I've tried using hiddenName: 'customerNumber' but it did not help. If name attribute is removed then no value is sent at all.

When I submit the combo to server, I am getting the displayField instead of the valueField.

What is wrong ?..this is very urgent !

Thanks for your help

Mikhail

30 Nov 2009, 11:24 AM
Mikhail, can you post the code for the store and combo in code tags? hiddenName should work.

mgoncharov
30 Nov 2009, 11:27 AM
Here's my store code:

var productStore = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
method: 'POST',
prettyUrls: false,
url: '/customappsweb/productsearchservlet'
}),
reader: new Ext.data.JsonReader({
root: 'rows',
totalProperty: 'total'
}, [
{name: 'partNumber'},
{name: 'manufacturer'},
{name: 'description'},
{name: 'category'},
{name: 'list'},
{name: 'myPrice'},
{name: 'status'},
{name: 'qty'}
]),
remoteSort: true
});

productStore.on('beforeload', function() {
productStore.baseParams = productSearchFm.getForm().getValues();
});
productStore.setDefaultSort('partNumber', 'asc');

Here's the Search button code:

buttons: [{
text: 'Search',
handler: function() {
productStore.removeAll();
productStore.load({
params:{start:0, limit:prodPageSize},
waitMsg:'Searching....'
});
}
}]

30 Nov 2009, 11:30 AM
your fields don't match the displayField and valueField. i'm confused

mgoncharov
30 Nov 2009, 11:37 AM
There are 2 stores here:

1st store is used to populate the combobox, when somebody starts typing in the box:

Ext.arrow.customerNumberDS = new Ext.data.Store({
url: '/customappsweb/getcustomernumber',
reader: new Ext.data.JsonReader({
root: 'rows'
}, [
{name: 'nu'},
{name: 'na'}
])
});

2nd store is used to search for the values selected on the form including the combobox listed above.

The first part works, when I start typing the customer number in the combobox I am getting back the correct values and combo is populated correctly.

Example: Typed 100000 got back few records.
Selected: 1000001 --> CDW (the text of the record in the combobox), value is 1000001

When I submit I 'd like to send value 100001 not the full text with --> CDW included !!!!

Is it clear now ?

Mikhail

mgoncharov
30 Nov 2009, 12:39 PM
Any ideas ?

bodyboarder20
26 Feb 2010, 10:31 AM
Did you find a solution to this? I am running into the same problem.

mgoncharov
26 Feb 2010, 10:49 AM
Yes, I did...this was totally my problem. I had in one place incorrect reference on the field.
HiddenName should work for you.

If it is still does not work, include the value in the display field and then parse on the server.

Mikhail

bodyboarder20
26 Feb 2010, 10:55 AM
Wow, oddly enough I was trying to that earlier, and it wasnt working, but I tried it again, and I dont know what I changed, but its working now! Thanks for the motivation to try it again ;-)