asp.net mvc+extJs3.01.后台返回的是Json
public ActionResult GetBrandMsg()
{
//获取所有品牌
List<Brand> brands = BrandManager.GetAllBrand();
//返回的json我打印了看了下,是这样的:
[{"Id":1,"BrandName":"雪弗兰"},{"Id":2,"BrandName":"别克"},{"Id":3,"BrandName":"宝马"}]
return this.Json(brands, JsonRequestBehavior.AllowGet);
}2.前台:
Ext.onReady(function() {
var myStore = new Ext.data.JsonStore({
autoLoad: true,
proxy: new Ext.data.HttpProxy({
url: "Car/GetBrandMsg"
}),
fields: ["Id", "BrandName"]
});
------------------------------------------------------
xtype: "combo",
name: "brands",
model: "remote",
store: myStore,
selectOnFocus: true,
loadingText: "正在加载数据",
triggerAction: "all",
displayField: "BrandName",
valueField: "Id",
fieldLabel: "品牌",
emptyText: "--请选择品牌--",
width: 200
------------------------------------------------------问题:combobox总是没有值显示,请高手帮忙看下是什么原因
public ActionResult GetBrandMsg()
{
//获取所有品牌
List<Brand> brands = BrandManager.GetAllBrand();
//返回的json我打印了看了下,是这样的:
[{"Id":1,"BrandName":"雪弗兰"},{"Id":2,"BrandName":"别克"},{"Id":3,"BrandName":"宝马"}]
return this.Json(brands, JsonRequestBehavior.AllowGet);
}2.前台:
Ext.onReady(function() {
var myStore = new Ext.data.JsonStore({
autoLoad: true,
proxy: new Ext.data.HttpProxy({
url: "Car/GetBrandMsg"
}),
fields: ["Id", "BrandName"]
});
------------------------------------------------------
xtype: "combo",
name: "brands",
model: "remote",
store: myStore,
selectOnFocus: true,
loadingText: "正在加载数据",
triggerAction: "all",
displayField: "BrandName",
valueField: "Id",
fieldLabel: "品牌",
emptyText: "--请选择品牌--",
width: 200
------------------------------------------------------问题:combobox总是没有值显示,请高手帮忙看下是什么原因
{"items":[{"Id":1,"BrandName":"雪弗兰"},{"Id":2,"BrandName":"别克"},{"Id":3,"BrandName":"宝马"}]}
var note = Ext.data.Record.create([
{name: 'Id'},
{name: 'BrandName'}
]);
var myStore = new Ext.data.GroupingStore({
url: "combo.asxg",
reader:new Ext.data.JsonReader({
root:"items"
},note)
});
var note = Ext.data.Record.create([{
name : 'Id'
}, {
name : 'BrandName'
}]);
var myStore = new Ext.data.JsonStore({
url : "combo.asxg",
root : "items",
fields : [{
name : "Id"
}, {
name : "BrandName"
}] });
var form1 = new Ext.form.FormPanel({
width : 350,
frame : true,// 圆角和浅蓝色背景
height : 300,
title : "FormPanel",
bodyStyle : "padding:5px 5px 0",
items : [ {
xtype : "combo",
name : "brands",
model : "local",
store : myStore,
selectOnFocus : true,
loadingText : "正在加载数据",
triggerAction : "all",
displayField : "BrandName",
hiddenName : "BrandName",
valueField : "Id",
fieldLabel : "品牌",
emptyText : "--请选择品牌--",
width : 200
}]
});
var mytabpanel = new Ext.TabPanel({
title : 'tab',
renderTo : "panel",//呈现
items : [form1],
activeTab : 0
});
});