0

I am Very new to EXTJS.

i am adding a new combo to my html page using EXTJS in xxx.js file and fetching the values from MVC controller with sample information.

while debugging the MVC application it is sending the sample information when i send URL: xxxx/getSite from EXTJS.

but it is not showing the values which are fetching from Controller. i am adding the below code which i am using.

Please let me know my mistake.

My Ext JS Code:

 var siteidStore = new Ext.data.JsonStore({
reader: new Ext.data.JsonReader({
fields: ['SiteName','SiteId']
}),
root: 'Site', 
proxy: new Ext.data.HttpProxy({
url: 'Site/getSite',
method: "POST", 
type: 'ajax', 
reader: 'json' 
}),
autoLoad: true
}); 


var combo = Ext.create('Ext.form.field.ComboBox', { 
queryMode: 'local',
store: siteidStore, 
fieldLabel: 'Site ID',
name: 'siteid',
displayField: 'SiteName',
valueField: 'SiteId',
triggerAction: 'all',
typeAhead: false, 
forceSelection: true,
emptyText: 'Select Site',
hiddenName: 'SiteId',
selectOnFocus: true 
});

MY MVC Appln Code from Controller:

publicActionResult getSite()
{
List<Combo> siteid = newList<Combo>();
siteid.Add(newCombo(1, "IND"));
siteid.Add(newCombo(2, "USA"));
siteid.Add(newCombo(3, "UK")); 
return Json(new
{
Site = siteid,
}, JsonRequestBehavior.AllowGet);
}

Output of my C# code or Json:

{"Site":[{"SiteName":"IND","SiteId":1},{"SiteName":"USA","SiteId":2},{"SiteName":"UK","SiteId":3}]}
  • Can anybody please look into this issue which i am facing?. Thanks – user2829997 Oct 01 '13 at 01:52
  • I got the partial solution: ` var StrSiteID = new Ext.data.JsonStore({ storeId: 'SiteIDStore', proxy: { type: 'ajax', url: 'Templates/getSite', reader: { type: 'json', root: 'Site' } }, fields: ['SiteName', { name: 'SiteId', type: 'number' }], autoLoad: true }); ` by using the above Store. But only PROBLEM i am facing now, i am not able to bind the values for combobox if it is placed inside the "XTYPE: CONTAINER" – user2829997 Oct 01 '13 at 09:00

1 Answers1

0

may be you forgot

renderTo : Ext.getBody()

inside combobox...

Eren
  • 226
  • 3
  • 3