PDA

View Full Version : Combobox



Gayathiri
30 Mar 2012, 2:59 AM
Am trying to populate a textfield from a combobox on clicking an add button. There are two textfields, onw which gets populated form the combobox and the other in which the user enters the value. But, am able to display the textfields but they are not getting populated. Code is as follows:


function loadPAGECONst() {
if(PAGECONst == null) {
PAGECONst = Ext.create('Ext.data.Store', {
model : 'SimpleModel',
proxy : {
type : 'ajax',
url : 'data/Pages.aspx',
reader : {
type : 'json',
root : 'Rows',
totalProperty : 'TotalRows'
},
actionMethods : {
create : 'POST',
read : 'POST'
},
extraParams : {
mode : 'PAGECONLIST',
UserID : USER.UserID,
limit : SYSTEM.listLimit
}
},
autoLoad : true
});
} else {
delete PAGECONst.lastParams
}
PAGECONst.proxy.extraParams.PageID = CRE8.pageID;
PAGECONst.proxy.extraParams.ProjDB = CRE8.projDB;

PAGECONst.load();
}



xtype : 'form',
title : 'Controls',
id : 'PDCONTROLS',
fieldDefaults : {
labelAlign : 'top'
},
defaultType : 'textfield',
defaults : {
width : 550
},
items:[{
xtype: 'form',
title: 'Add Control',
id: 'ADDCONTROL',
defaultType:'textfield',
maxLength: 500,
bodyPadding : 10,
defaults : {
width : 300
},
items:[ControlC],
buttons:[{
text: 'Add',
handler: function(){
var form = Ext.getCmp('ADDCONTROL');
if(form.getForm().isValid()){
form.getForm().submit({
url : 'data/Pages.aspx',
params : {
UserID : USER.UserID,
mode : 'ADDCONTROL',
ProjDB : CRE8.projDB,
PageID : CRE8.pageID
},
success : function() {
loadPAGECONst();
//addPageControls();
genMessage(LANG.Suc, LANG.SaveOK, 'tick', false);
},
failure : function() {
genMessage(LANG.Warn, LANG.GenWarn, 'warn', false);
},
});





fp.on('afterRender', function() {
fp.on('afterRender', function() {CONTROLLIST = Ext.getCmp('CONTROLLIST');
for(x=0; x < numCtrls; x++){
var CtrlVal = {
id: 'CTRLVAL_' + PAGECONst.getAt(x).get('itemID'),
name: 'CTRLVAL_' + PAGECONst.getAt(x).get('itemID'),
value: PAGECONst.getAt(x).get('Title'),
width: 150
}
var CtrlFunc = {
id: 'CTRLFUNC_' + PAGECONst.getAt(x).get('itemID'),
name: 'CTRLFUNC_' + PAGECONst.getAt(x).get('itemID'),
value: PAGECONst.getAt(x).get('Title'),
width: 250
}
var CtrlDelChk = {
xtype : 'checkbox',
id : 'CTRLDEL_' + PAGECONst.getAt(x).get('con_ind'),
name : 'CTRLDEL_' + PAGECONst.getAt(x).get('con_ref'),
padding: '0 0 0 20',
width: 100
}
CONTROLLIST.add([CtrlVal, CtrlFunc, CtrlDelChk]);
}
loadPageForm(panelID);
});



Many thanks in advance.

scottmartin
30 Mar 2012, 2:58 PM
Perhaps this may help:




// Simple ComboBox using the data store
var combo = Ext.create('Ext.form.field.ComboBox', {
id: 'idcombo', // using id for demo purposes
fieldLabel: 'Select state',
renderTo: Ext.getBody(),
displayField: 'name',
width: 250,
labelWidth: 80,
store: store,
typeAhead: true
});

// Simple ComboBox using the data store
var field = Ext.create('Ext.form.field.Text', {
id: 'idfield', // using id for demo purposes
fieldLabel: 'Text field',
renderTo: Ext.getBody(),
displayField: 'name',
width: 250,
labelWidth: 80
});

var button = new Ext.Button({
text: 'Update Text field',
width: 150,
renderTo: Ext.getBody(),
handler: function(){
var cmb = Ext.getCmp('idcombo'), // getCmp for demo purposes
fld = Ext.getCmp('idfield');

fld.setValue(cmb.getValue());
}
});


Regards,
Scott.