ExtJs Combobox绑值问题

qzw4549689 2010-04-29 04:43:06
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
},

...........

急等高手解决!!!
...全文
119 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
十橙心橙意 2010-04-29
  • 打赏
  • 举报
回复
直接用JSONObject 和 JSONArray 封装json格式
KK3K2005 2010-04-29
  • 打赏
  • 举报
回复
太多写法
不想贴代码 自己接网上搜个例子吧
qzw4549689 2010-04-29
  • 打赏
  • 举报
回复
高手!快来!加分!

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧