PDA

View Full Version : Value, Primary Key and ComboBox



rvent
25 Apr 2008, 11:33 AM
Hello,

I have this combo box whose data store gets PartState and PartStateID. The comboBox displays whats meaninful for the user (PartState) when user finishes with the form and it is submited i would like to send the PartStateID on the _POST and not the displayed value.

I want to do it this way since i have already queried the DB for the data and i really dont see any point on querying again just to get the ID of the selected value. Since technically all could be done in one request.

I tried valueField, but it doesnt show any data.

Is there any way to accomplish it...?


Thanks

25 Apr 2008, 11:48 AM
valueField does just that. The examples show how to do this.
Are you using json or arrays? Have you mapped your data accordingly?

rvent
25 Apr 2008, 12:02 PM
I am passing a json formated data string.



var dataRecordPriority = new Ext.data.Record.create([
{name: 'PartPriority'},
{name: 'PartPriorityID'}
]);

var dataReaderPriority = new Ext.data.JsonReader({
root: 'results'
},
dataRecordPriority
);

var dataProxyPriority = new Ext.data.HttpProxy({
url: '../../../index.php/listboards/js_listPriorities',
method: 'POST'
});

var dataStorePriority = new Ext.data.Store({
proxy: dataProxyPriority,
reader: dataReaderPriority
});

var priority = new Ext.form.ComboBox({
store: dataStorePriority,
fieldLabel: 'Part Priority',
valueField: 'PartPriorityID',
displayField:'PartPriority',
name: 'PartPriority',
allowBlank: false,
typeAhead: true,
mode: 'remote',
triggerAction: 'all',
valueNotFoundText:'Select a Priority...',
emptyText:'Select a Priority...',
selectOnFocus:true,
width: 120
});


I dont see what i am missing... If I change the displayField to PriorityID it shows the Keys, when when i use it on the valueField it doesnt get sent on the _POST

And i dont see anything wrong with my submit:


submit: function() {
var formDom = addPart.form.getEl().dom;
formDom.action = this.url;
formDom.method = this.method;
formDom.submit();
},
buttons: [{
text: 'Save',
formBind:true,
handler: function(){
addPart.form.submit();
}
}],


(:|:-/

Thanks

25 Apr 2008, 12:04 PM
add a hiddenName attribute, see if that helps.

rvent
25 Apr 2008, 12:15 PM
WOW.. Thanks man...

I would have never thought of that...

Thanks..!=D>

25 Apr 2008, 12:37 PM
You're welcome. I was in your shoes once.