PDA

View Full Version : combobox submit value issue, DESPERATE for an answer



fatnjazzy
28 Mar 2011, 12:10 AM
Hi,
I have a form with combo (hiddenName como).
the form load its data from the server and set the "selectedValue" automatically.
the combo load its value from the server before the form loads its data.
If I click on submit, the display will be sent to the server instead if the value even though i set the hiddenName.
but if i change the combo value, from now and on it will submit the value and not the display, as expected.
Y the initial value that was set by the form prevents the combo to submit its value...?

this is the combo and the store:


var store = new Ext.data.JsonStore({
autoLoad: true,
url: config.url,
root: 'data',
methos:'POST',
fields:[{name:'userManager_employeeId'},{name:'userManager_userName'}] });

var combo = new Ext.form.ComboBox({
hiddenName:'userManager',
valueField: 'userManager_employeeId',
displayField: 'userManager_userName',
forceSelection: true,
mode: 'remote',
typeAhead: true,
lazyInit :false,
lazyRender:false,
fieldLabel: config.title,
emptyText:'Select a value',
roles:config.roles,

this is the form data:


{"data":[{"employee_employeeId":3,"Affiliate_affiliateId":8,"parent_affiliateId":8,"userManager_employeeId":1,"Affiliate_email":"[email protected]","parent_name":"First Affiliate","userManager":"admin","Affiliate_name":"First Affiliate","user_userName":"admin","user_userId":1}]}


this is the combo data:


{"data":[{"userManager_userName":"admin","userManager_employeeId":3},{"userManager_userName":"admin2","userManager_employeeId":4}]}

this is the form reader:


reader: new Ext.data.JsonReader({
root: 'data',
fields: [{
name: 'userManager'
}]
})
this is the form data:


{"data":[{"userManager":"admin"}]}
I also tried:


{"data":[{"userManager":"1"}]}

if the form data is "admin", I see in the display admin but the submitted value us admin
but if the form data is "1", I see in the display "1" and in the submit value "1" How can i see in the display admin and submit the value ("1") Thanks

tvanzoelen
28 Mar 2011, 6:10 AM
I dont know but yout reader seems a bit simple and your store contains field

Maybe something like this




var datareader = new Ext.data.JsonReader({id: 'userManager_employeeId', totalProperty: 'total',
root: 'data',
succesProperty: 'success'},
Ext.data.Record.create(
[{name: 'userManager_employeeId', mapping: 'userManager_employeeId', type: 'int'},
{name: 'userManager_userName', mapping: 'userManager_userName', type: 'string'}
]));



var datastore = new Ext.data.Store({id:'datastore',
reader:datareader,
url: 'yourdataurl.jsn'
});


var combo = new Ext.app.ComboBox({
id:'mycombo',
store:datastore,
displayField: 'userManager_userName',
valueField: 'userManager_employeeId',
mode: 'local',
triggerAction: 'all'
});

kohyea
28 Mar 2011, 12:26 PM
Hello, Please check your combo data:


{"data":[{"userManager_userName":"admin","userManager_employeeId":3},{"userManager_userName":"admin2","userManager_employeeId":4}]}
You only have 2 records, and the ID is 3 or 4, not 1, you should set the value of field userManager as 3 or 4 on the form data.

Please try it,

Kohyea

fatnjazzy
29 Mar 2011, 10:32 PM
Thanks !!!
It was a combination of all of you,
Thanks again.