PDA

View Full Version : Overriding ComboBox behaviour



AkshayKalbhor
7 Mar 2014, 3:11 AM
Hi,

I have a few comboBoxes in my Form, At the form submit event I want the combobox to return a object rather than just the value,

I want the value as follows

{"setting":{"id":2,"fieldName":"TF"},"value":"24HM"}

Can any one please help me as which method of comboBox should i override?

Help appreciated.

Regards.
Akshay

chramer
7 Mar 2014, 4:37 AM
You should override the "getSubmitValue" method
Docs: http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.ComboBox-method-getSubmitValue

AkshayKalbhor
10 Mar 2014, 1:39 AM
Sorry for the formatting, I overrode the getSubmitData as follows,

Ext.define('APP.view.common.SettingsCombo', { extend : 'Ext.form.field.ComboBox',
alias : 'widget.settingCombo',
valueField: 'name',
displayField: 'name',
settingId: null,
settingName: null,

getSubmitData: function() {
var me = this,
data = null,
value;
if (!me.disabled && me.submitValue && !me.isFileUpload()) {
value = me.getValue();
if (value !== null) {
var dataValue = new Object();
var organizationSettings = new Object();
var setting = new Object();
setting.id = this.settingId;
setting.fieldName=this.settingName;// settingName
dataValue.setting=setting;
dataValue.value = value;
organizationSettings.organizationSettings=dataValue;
data=organizationSettings;
}
}
return data;
}


});