PDA

View Full Version : Grid.show() button works... but not first time?



mice-pace
17 Dec 2012, 6:27 PM
I ran into the wierdest little problem, I have a button to hide/show a grid... based on the text of the button which changes itself (the description needs to change each time, so why not use it to track the state?) a grid is made to be .show()-n or .hide()-n (Shown or Hidden, incase you didn't get my terrible pun ;))


xtype: 'button',
colspan: 1,
text: 'Show Old',
listeners: {
click: {
fn: me.onButtonClick1,
scope: me
}
}

onButtonClick1: function(button, e, options) {
var old = Ext.getCmp('cmp_goahead_contractlist');


if(button.text == 'Show Old')
{
alert("showing old3");
button.setText('Hide Old');
old.show();
}else{
//alert("hiding old");
button.setText('Show Old');
old.hide();
}
},


onDisplayGABeforeRender: function(abstractcomponent, options) {
var old = Ext.getCmp('cmp_goahead_contractlist');
old.hide();
},


So Before the container they are both in is rendered, the ContractList is hidden (using .hide() ), the default text on the button is 'Show Old'... And when i click it for the first time it alerts "showing old3" (all good so far)... but then doesn't make it visible!

After clicking 'Hide Old' to change it back then clicking 'Show Old' again it works just fine... and works fine every time after that!

The method is triggering (because i get the alert at the right section)
I'm not getting any errors at all
It's not to do with click 'Hide Old' before 'Show Old' works (if i set the default to 'Hide Old' i need to click Hide, Show, Hide, Show before anything happens)
Running show() then show() again doesn't stop it, and neither does running hide() then show()

mice-pace
17 Dec 2012, 7:18 PM
Two reasons for this problem apparently...

When i made a store for it suddenly it was visible... which means beforeRender wasn't hiding it, it was simply failing to show up because it didn't have a store.

Secondly I was using tabs, so rather than beforeRender i should have use onActivate