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}]}