首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >组合框中的默认值作为存储中的值

组合框中的默认值作为存储中的值
EN

Stack Overflow用户
提问于 2014-06-10 22:32:21
回答 1查看 107关注 0票数 0

我正在尝试在我的组合框中将我的json商店的返回值获取到setValue。此json值的值是数据库中当前选定的选项。我的this.selectedCat存储返回它所在的记录的当前类别值。我的this.store返回所有可用的选择选项。

代码语言:javascript
运行
复制
  var fields = {
  fields: ['text'] 
};
var notfields ={
  fields:['category']
}
this.store = new GO.data.JsonStore({
  url: GO.settings.modules.infoscherm.url + 'json.php',
  baseParams:{
    task:'selects'
  },
  root: 'results',
  fields: fields.fields
});

  this.selectedCat = new GO.data.JsonStore({
  url: GO.settings.modules.infoscherm.url + 'json.php',
  baseParams: {
    task:'currentselectedcat',
    id:'id'
  },
  root: 'results',
  fields: notfields.fields
});


  this.category = new Ext.form.ComboBox({
  name: 'category', 
  width: 100,
  store: this.store, 
  fieldLabel: "Categorie", 
  displayField:'text', 
  triggerAction: 'all', 
  editable: false, 
  selectOnFocus:true, 
  value: this.selectedCat //returns [object Object] naturally
});

我做错了什么吗?

EN

回答 1

Stack Overflow用户

发布于 2014-06-11 19:04:00

我认为你需要开始监听"Ext.data.JsonStore“的"load”事件。附加的"load“事件处理程序将包含通过使用combobox对象的"setValue”函数选择任何特定值的代码...

附注:仅当您将combobox的" Store“配置配置为store对象时,存储值才会在combobox下拉菜单中可用,在您的情况下,您需要在"load”事件的处理程序中实现一些逻辑。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24143692

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档