当前位置: 代码迷 >> JavaScript >> ExtJs Combobox绑值有关问题
  详细解决方案

ExtJs Combobox绑值有关问题

热度:1289   发布时间:2012-04-05 12:42:40.0
ExtJs Combobox绑值问题
asp.net mvc+extJs3.0

1.后台返回的是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总是没有值显示,请高手帮忙看下是什么原因

------解决方案--------------------
你的数据格式有错
{"items":[{"Id":1,"BrandName":"雪弗兰"},{"Id":2,"BrandName":"别克"},{"Id":3,"BrandName":"宝马"}]}

------解决方案--------------------
autoLoad:false
------解决方案--------------------
确定你的store到后台去请求了数据?
  相关解决方案