PDA

View Full Version : Load data into Combo



malkandari
7 Apr 2010, 7:48 AM
Hey guys,

I am using JSON to retrieve drop down values from MySQL. The problem is when I load the data. In the comboBox.. It shows the value instead of the Name...

Here is my combo definition



var campaignsTypeStore = new Ext.data.JsonStore
({
url: 'php/campaignTypes.php',
baseParams:{cmd:'campaignsType'},
root: 'campaignsType',
fields: ['typeID', 'typeName']
});

var campaignsTypeCombo1={
xtype: 'combo',
name: 'campaignType',
hiddenName: 'campaignType',
store: campaignsTypeStore,
displayField: 'typeName',
valueField: 'typeID',
editable: false,
mode: 'remote',
forceSelection: true,
triggerAction: 'all',
fieldLabel: 'Type',
emptyText: 'Select a Type...',
selectOnFocus: true,
width:250
}
And this is my call to the combo


var formCampaignInfo1 =
{
border: false,
bodyStyle: 'background:transparent',
columnWidth: .5,
layout: 'form',
items: [
{
xtype: 'textfield',
fieldLabel: 'Campaign ID',
name: 'campaignID',
anchor: '95%'
},
campaignsTypeCombo1
]
}
This is the combo Value returned "php/campaignTypes.php"


{"campaignsType":[
{"typeID":"1","typeName":"TeleSales"},
{"typeID":"2","typeName":"Mail"},
{"typeID":"3","typeName":"Email"},
{"typeID":"4","typeName":"Print"},
{"typeID":"5","typeName":"Web"},
{"typeID":"6","typeName":"Radio"},
{"typeID":"7","typeName":"Television"},
{"typeID":"8","typeName":"Newsletter"}]}This is what PHP Returns



{success:true,data:{id:'1',campaignID:'LeadsDirect2',campaignName:'Leads Direct - Agreed!!',campaignType:'2',budget:'0.00',actualCost:'101.99',expectedCost:'0.00',expectedRevenue:'0.00',endDate:'0000-00-00',objective:'This is the best and I\'m testing!!',description:'gfgfdg',assignedTo:'2',createdBy:'CRM Admin',createdOn:'0000-00-00 00:00:00',modifiedOn:'2010-04-06 17:25:03'}}


Can anyone help please? If you need more info, please let me know..

Thank You,

GoneIn20Seconds
7 Apr 2010, 9:26 AM
How are you getting the campaignType out of the JSON string and telling the combo box what it's selected value should be?

malkandari
7 Apr 2010, 10:40 AM
I have a grid, and when you double click a row, it shows a window... Here is the call



campaignsGrid.on('rowdblclick', function(campaignsGrid, rowIndex)
{
var val = campaignsGrid.store.getAt(rowIndex).get('id');
winCampaign.show();
Ext.getCmp('campaignForm').getForm().load({ url: 'php/getInfo.php', params:{id: val, action: 'campaign' },waitMsg: 'Loading Form...'});

});
Thank You