我正在尝试使用项目名称列表填充组合框。我能够成功获取所有项目名称,但我似乎无法弄清楚如何将它们作为自定义数据集添加到组合框中。我已经研究过使用其他类型的组合框(迭代,组合,属性等),但它们似乎没有能力将自定义数据添加到它们的下拉列表中(除非我弄错了)。这是我用于组合框的代码:
this.down = this.add({
xtype: 'rallycombobox',
storeConfig: [{
model: 'Project',
autoLoad: true,
fieldLabel: 'Projects:',
data: this.project_names,
width: field_width
}]
});
当尝试使用此代码运行时,我得到一个“未捕获的TypeError:无法调用未定义的方法'getProxy'。我无法弄清楚如何让它工作。我还尝试了以下内容:
this.down = this.add({
xtype: 'rallycombobox',
model: 'Project',
fieldLabel: 'Projects:',
data: this.project_names,
width: field_width
});
我仍然以同样的错误结束。任何人都可以帮我解决我做错的事吗?谢谢!
答案 0 :(得分:0)
如果你已经有一个项目列表,你想在ComboBox中使用,而不是Rally ComboBox,我建议你只使用Ext ComboBox。 Rally ComboBox旨在通过查询反弹中的数据来填充其存储 - 因此在尝试将Rally WSAPI存储与本地数据混合和匹配时,您会看到getProxy
错误。
设置可能如下所示。
// The data store containing the list of Projects
var projectStore = Ext.create('Ext.data.Store', {
fields: ['_ref', 'Name'],
data : [
{"_ref": "/project/12345678910", "Name": "Project 1"},
{"_ref": "/project/12345678911", "Name": "Project 2"},
{"_ref": "/project/12345678912", "Name": "Project 3"}
//...
]
});
// Create the combo box, attached to the Projects data store
this.projectSelector = Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose Project',
store: projectStore,
queryMode: 'local',
displayField: 'Name',
valueField: '_ref',
listeners:{
scope: this,
select: function(combobox) {
// Do stuff here
console.log('Ref of Project Selected: ' + this.projectSelector.getValue());
}
}
});
this.down('#projectSelectorContainer').add(this.projectSelector);
希望这很有帮助。如果有后续问题,请告诉我们。
答案 1 :(得分:0)
这可能会对您有所帮助:
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
//Write app code here
var projectStore = Ext.create('Rally.data.WsapiDataStore',{
model: 'project',
fetch: ['Name','ObjectID'],
autoLoad: true,
// filters:[{
// property:'ObjectID',
// operator:'=',
// value: __PROJECT_OID__
// }],
listeners:{
load: function(store,records,success){
this._updateCombo(store);
},
scope: this
}
});
console.log('/project/',__PROJECT_OID__);
},
_loadCombo: function(myStore){
this._myCombo = Ext.create('Ext.form.ComboBox',{
fieldLabel: 'Choose Project',
store: myStore,
queryMode: 'remote',
displayField: 'Name',
valueField: 'Name',
listeners: {
select: function(combobox,records){
console.log(records[0]["data"]["Name"]);
}
},
scope:this
});
this.add(this._myCombo);
},
_updateCombo: function(myStore){
if(this._myCombo === undefined){
this._loadCombo(myStore);
}else{
this._myCombo.clearValue();
}
}
});