0

我对 EXTJS 很陌生。

我正在使用 xxx.js 文件中的 EXTJS 向我的 html 页面添加一个新组合,并使用示例信息从 MVC 控制器中获取值。

在调试 MVC 应用程序时,当我从 EXTJS 发送 URL:xxxx/getSite 时,它​​正在发送示例信息。

但它没有显示从控制器获取的值。我正在添加我正在使用的以下代码。

请让我知道我的错误。

我的分机 JS 代码:

 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 代码:

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);
}

我的 C# 代码或 Json 的输出:

{"Site":[{"SiteName":"IND","SiteId":1},{"SiteName":"USA","SiteId":2},{"SiteName":"UK","SiteId":3}]}
4

1 回答 1

0

可能你忘了

renderTo : Ext.getBody()

在组合框内...

于 2013-10-10T11:21:27.797 回答