Combobox 组合框不显示第二次加载窗口时的记录
我已经为一个问题挣扎了一两天了。我有一个包含2个组合框的外部窗口。在第一次加载时,一切正常,两个存储都已填充,组合的工作也应如此 但是,如果I.show()再次打开窗口,组合框不会“下拉”显示列表。我已经检查了Firebug,虽然商店正在填充,但是没有条目被添加到组合框中 以下是窗口的代码:Combobox 组合框不显示第二次加载窗口时的记录,combobox,extjs,Combobox,Extjs,我已经为一个问题挣扎了一两天了。我有一个包含2个组合框的外部窗口。在第一次加载时,一切正常,两个存储都已填充,组合的工作也应如此 但是,如果I.show()再次打开窗口,组合框不会“下拉”显示列表。我已经检查了Firebug,虽然商店正在填充,但是没有条目被添加到组合框中 以下是窗口的代码: uTransferWindow = new Ext.Window({ id : 'windowUserLicenseTransfer',
uTransferWindow = new Ext.Window({
id : 'windowUserLicenseTransfer',
title : 'Title',
width : 405,
autoScroll : true,
closeAction : 'hide',
closable : false,
modal : true,
bodyStyle : 'background-color:#FFF',
buttonAlign : 'center',
items : new Ext.form.FormPanel({
labelAlign : 'left',
labelWidth : 140,
bodyStyle : 'padding:10px 10px 0 10px',
border : false,
defaults: {
xtype: 'ComboBox',
anchor: '100%',
tpl: '<tpl for="."><div class="x-combo-list-item"><div style="position:absolute;left:4px;">{initials}</div><div style="position:relative;left:50px;">{username}</div></div></tpl>',
displayField: 'username',
valueField: 'userid',
typeAhead: true,
mode: 'local',
triggerAction: 'all'
},
items: [{
hiddenName: 'fromuserid',
fieldLabel: 'From User',
id : 'drop1',
store: userswithlicenses
}, {
hiddenName: 'touserid',
fieldLabel: 'To User',
id : 'drop2',
store: userswithoutlicenses
}]
}),
buttons : [{
text : 'Transfer License',
handler : function() {
//do stuff
}
}, {
text: 'Cancel',
handler: function() { uTransferWindow.hide(); }
}]
}),
uTransferWindow=新的外部窗口({
id:'windowUserLicenseTransfer',
标题:“标题”,
宽度:405,
autoScroll:是的,
closeAction:'隐藏',
可关闭:错误,
莫代尔:是的,
bodyStyle:'背景色:#FFF',
buttonAlign:'中间',
项目:新的Ext.form.FormPanel({
labelAlign:'左',
标签宽度:140,
车身风格:“衬垫:10px 10px 0 10px”,
边界:错,
默认值:{
xtype:“组合框”,
主播:100%,
tpl:“{initials}{username}”,
显示字段:“用户名”,
valueField:'用户ID',
是的,
模式:“本地”,
触发动作:“全部”
},
项目:[{
hiddenName:'fromuserid',
fieldLabel:'来自用户',
id:'drop1',
商店:userswithlicenses
}, {
hiddenName:“图塞里德”,
fieldLabel:“给用户”,
id:'drop2',
存储:userswithoutlicenses
}]
}),
按钮:[{
文本:“转让许可证”,
处理程序:函数(){
//做事
}
}, {
文本:“取消”,
处理程序:函数(){uTransferWindow.hide();}
}]
}),
我还没有在论坛上找到其他有类似问题的人,如果有任何帮助,我将不胜感激
更新:发现了一些小问题:当第二次显示窗口时,z索引确实增加了。为什么每次显示窗口时z索引都会增加?您最好不要显示/隐藏窗口,而是创建一个新窗口,并在需要时关闭它。这可以通过使用 我相信,这种方法将有助于解决您遇到的问题,并将保留html代码以避免隐藏窗口
<> P.S.S.您也可以考虑使用命名空间().< /p> 确保您不多次调用新ExtEnter——因为您隐藏窗口而不是销毁,如果用相同配置调用新的窗口,则组合框的ID将冲突并具有描述的行为。 我也遇到了同样的问题,这是一个z索引问题(firebug显示了这种情况)。组合的列表不包含在窗口的div中,因此窗口的z索引更改不会级联到列表视图。不管怎样,我没有注意到每次显示窗口时都会更新其z索引,但随后打开的窗口将接收更高的z索引。这是当我收到问题,打开多个窗口 在我的例子中,我扩展了Ext.Window并在任何地方都使用了该扩展,所以我只是在扩展的initComponent中放置了一个“beforeshow”侦听器,如下所示:
initComponent: function(){
... // I put the listener as the last line
this.on("beforeshow", this.fixComboDropdowns, this);
},
/**
* When opening multiple windows within an application, combo box list values' zIndex
* can become out-of-sync and cause the list to not show its values. This
* method is to help prevent that from occurring.
*/
fixComboDropdowns: function(win){
try{
var zIndex = parseInt(win.getEl().getStyle("z-index"));
// retrieve the combo boxes contained in this window.
// call each combo boxes' getListParent() method, and set the list parent's zindex.
var combos = win.findByType("combo");
if(combos && combos.length > 0){
if(WINDOW_ZINDEX === 0 || WINDOW_ZINDEX < zIndex){
WINDOW_ZINDEX = zIndex + 100;
}
else{
WINDOW_ZINDEX = WINDOW_ZINDEX + 100;
}
for(var index = 0; index < combos.length; index = index + 1){
// set each combo's z-index style:
var combo = combos[index];
var listEl = combos[index].getListParent();
if(listEl && listEl.style){
listEl.style.zIndex = WINDOW_ZINDEX + 10; // make sure the combo's list will display.
}
}
}
}catch(ex){
if(console){
console.error(ex);
}
}
return true;
}
initComponent:function(){
…//我把侦听器放在最后一行
this.on(“beforeshow”,this.fixCombo下拉列表,this);
},
/**
*在应用程序中打开多个窗口时,组合框会列出值“zIndex”
*可能会变得不同步,并导致列表不显示其值。这
*方法是帮助防止这种情况发生。
*/
fixComboDropdowns:函数(win){
试一试{
var zIndex=parseInt(win.getEl().getStyle(“z-index”);
//检索此窗口中包含的组合框。
//调用每个组合框的getListParent()方法,并设置列表父对象的zindex。
var combos=win.findByType(“combo”);
if(combos&&combos.length>0){
if(WINDOW_ZINDEX==0 | | WINDOW_ZINDEX
哦,别忘了定义全局窗口_ZINDEX变量,如下所示:
var WINDOW_ZINDEX=0
我相信上面的代码是可以改进的,但是你已经了解了大概的意思。一些我无法验证的项目:
1). 如果弹出窗口将焦点设置在某个字段上,该怎么办?上述情况是否消除了这种关注
如果你没有对Ext.Windows的重写,那么考虑使用工厂模式,在那里可以创建Ext.Windows,然后在返回给调用者之前将“BeSoWoWHO”侦听器放在它上面。 <
initComponent: function(){
... // I put the listener as the last line
this.on("beforeshow", this.fixComboDropdowns, this);
},
/**
* When opening multiple windows within an application, combo box list values' zIndex
* can become out-of-sync and cause the list to not show its values. This
* method is to help prevent that from occurring.
*/
fixComboDropdowns: function(win){
try{
var zIndex = parseInt(win.getEl().getStyle("z-index"));
// retrieve the combo boxes contained in this window.
// call each combo boxes' getListParent() method, and set the list parent's zindex.
var combos = win.findByType("combo");
if(combos && combos.length > 0){
if(WINDOW_ZINDEX === 0 || WINDOW_ZINDEX < zIndex){
WINDOW_ZINDEX = zIndex + 100;
}
else{
WINDOW_ZINDEX = WINDOW_ZINDEX + 100;
}
for(var index = 0; index < combos.length; index = index + 1){
// set each combo's z-index style:
var combo = combos[index];
var listEl = combos[index].getListParent();
if(listEl && listEl.style){
listEl.style.zIndex = WINDOW_ZINDEX + 10; // make sure the combo's list will display.
}
}
}
}catch(ex){
if(console){
console.error(ex);
}
}
return true;
}