ExtJs Combobox绑值问题
1.后台代码:
public ActionResult GetBrandMsg()
{
//获取所有品牌
List<Brand> brands = BrandManager.GetAllBrand();
string jsonStr = "";
for (int i = 0; i < brands.Count; i++)
{
if (i == brands.Count - 1)
{
jsonStr += "{'brandName':'" + brands[i].BrandName + "','brandId':" + brands[i].Id + "}";
}
else
{
jsonStr += "{'brandName':'" + brands[i].BrandName + "','brandId':" + brands[i].Id + "},";
}
}
//1.不知道这样返回有没问题
return Json("{" + jsonStr + "}");
}
2.前台关键代码:
...........
Ext.onReady(function() {
var myStore = new Ext.data.JsonStore({
autoLoad: true,
proxy: new Ext.data.HttpProxy({
url: "Car/GetBrandMsg"
}),
fields: ["brandName"]
});
//这里弹出来是[object Object] alert(myStore);
//提示信息初始化
Ext.QuickTips.init();
//提示方式
Ext.form.Field.prototype.msgTarget = 'side';
//生成表单
var LeaveForm = new Ext.FormPanel({
width: 360,
frame: true,
renderTo: AddCarMsg,
title: "添加车辆信息",
bodyStyle: "padding:5px 5px 0",
id: "addCarForm",
items: [
{
xtype: "combo",
name: 'brand',
model: "remote",
displayField: "brandName",
fieldLabel: "品牌",
emptyText: '--请选择品牌--',
store: myStore, width: 200
},
...........
急等高手解决!!!