PDA

View Full Version : [FIXED] Updating a menu layout?



stever
8 May 2009, 10:56 AM
Updating a menu (say, do to loading results into a store from a webservice or similar), doesn't update the layout. Anyone have an idea on how to do this?

Example:


new Ext.Window({
height: 150,
width: 400,
tbar: [{
text: 'Test Menu',
menu: {
items: {
itemId: 'loading',
icon:'http://extjs.com/deploy/ext-3.0-rc1.1/resources/images/default/grid/loading.gif',
text: 'Loading'
},
listeners: {
show: function(){
if (!this.loadingDone) {
this.remove('loading');
this.add({
text: 'test'
});
this.add({
text: 'test'
});
this.add({
text: 'test'
});
this.add({
text: 'test'
});
this.add({
text: 'test'
});
this.loadingDone = true;
this.doLayout();
}
},
delay: 500
}
}

}]
}).show();

The second time you open the menu it is ok (the first image below, the second image is the the bad layout I'm trying to fix)

tryanDLS
8 May 2009, 11:45 AM
Just a shot in the dark, but what if you do that in beforeshow instead of show?

stever
8 May 2009, 6:25 PM
No difference. The point is that the update happens after the menu is shown -- thus the delay option in there. Just adding things on beforeshow works fine. My question is about adding after it is shown. Sort of like how the combo box can change size after a related store is loaded.

Animal
8 May 2009, 11:43 PM
It's a bug caused by the height trimming imposed by the default true setting of enableScrolling.

Set it to false, and it works a bit better.

doLayout needs to sync the shadow though:



new Ext.Window({
height: 150,
width: 400,
tbar: [{
text: 'Test Menu',
menu: {
enableScrolling: false,
items: {
itemId: 'loading',
icon:'http://extjs.com/deploy/ext-3.0-rc1.1/resources/images/default/grid/loading.gif',
text: 'Loading'
},
listeners: {
show: function(){
if (!this.loadingDone) {
this.remove('loading');
this.add({
text: 'test'
});
this.add({
text: 'test'
});
this.add({
text: 'test'
});
this.add({
text: 'test'
});
this.add({
text: 'test'
});
this.loadingDone = true;
this.doLayout();
this.el.sync();
}
},
delay: 500
}
}

}]