ExtJs Combobox绑值问题

qzw4549689 2010-04-29 02:35:52
1.后台返回传一个泛型集合List<xxx>
public ActionResult AddCarMsg()
{
List<Brand> brands = BrandManager.GetAllBrand();
ViewData["brands"] = Json(brands);
return View();
}

2.前台要把brands绑定到combobox上
非关键代码省略:
.............

var LeaveForm = new Ext.FormPanel({
width: 360,
frame: true,
renderTo: AddCarMsg,
title: "添加车辆信息",
bodyStyle: "padding:5px 5px 0",
id: "addCarForm",
items: [
{
xtype: "combo",
name: 'brand',
store: //这里应该如何绑定? fieldLabel: "品牌",
emptyText: '请选择品牌'

},
.............

请教
...全文
113 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhaocong112 2010-04-29
  • 打赏
  • 举报
回复
var findAllUserStore = new Ext.data.JsonStore({
autoLoad:true,
proxy:new Ext.data.HttpProxy({
url:"findAllUser.action"
}),
fields:["name"]
});

xtype:"combo",
emptyText:"选择网络客服",
id:"myweb",
mode:"remote",
selectOnFocus:true,
loadingText:"正在加载数据",
triggerAction:"all",
displayField:"name",
store:findAllUserStore

zhaocong112 2010-04-29
  • 打赏
  • 举报
回复
额 , 如果是放在combo里面,因为只有一个属性值 你可以用out.println(Json格式的数据)
在前台 store的url指向这个地址
就可以, Json格式数据 如:[{name:"张三"},{name:"李四"}]

qzw4549689 2010-04-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 zhaocong112 的回复:]
Brand类 里面有多个属性, 你可以用Json数据,或者你可以输出[{name:"name"}] 等,可以解决 在store 时候 用render解析就可以
[/Quote]
能不能详细点,后台有没什么方法能将集合直接转为Json的,还有render怎么解析啊 ,谢谢啦,我是Ext新手
asdujiayong 2010-04-29
  • 打赏
  • 举报
回复
store 首先要有请求的url地址
还要给他一个reader ,让它知道如何去阅读返回的数据
zhaocong112 2010-04-29
  • 打赏
  • 举报
回复
Brand类 里面有多个属性, 你可以用Json数据,或者你可以输出[{name:"name"}] 等,可以解决 在store 时候 用render解析就可以
qzw4549689 2010-04-29
  • 打赏
  • 举报
回复
高手快来!

87,910

社区成员

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

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