我正在寻找一个load侦听器,当组合框启动时,load将被调用并向服务器执行 ajax 以获得组合框的正确显示值。
但是,加载函数永远不会被调用..我该如何修复它?
我想在组合框之前显示文本,所以我添加了属性fieldLabel: 'Save logs to:'
。但文本不显示。
谢谢,
尤尼
this.log_save_combo = new Ext.form.ComboBox
({
store: ['Device', 'USB1', 'USB2']
, id: 'cplogs_log_save_combo'
, name: 'cplogs_log_save_combo'
, triggerAction:'all'
, fieldLabel: 'Save logs to:'
, editable: false
//, value: "Device"
, listeners: {
'load': function(){
alert("in load function");
}
});
作为问题的一般解决方案,我选择了
listeners:{
scope: this,
afterRender: this.selectFirstComboItem
}
with
selectFirstComboItem: function(combo) {
// This will tell us if the combo box has loaded at least once
if (typeof combo.getStore().lastOptions !== "undefined") {
// Grab the first value from the store
combo.setValue(combo.getStore().first().get(combo.valueField));
}
else {
// When the store loads
combo.getStore().on("load", function(store, items){
// Grab the first item of the newly loaded data
combo.setValue(items[0].get(combo.valueField));
});
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)