alex9311
29 Oct 2012, 3:17 PM
Hey all,
I'm working with two panels which are side by side (using the column layout). I'm interested in having the panels switch to being one on top of the other when the viewport width (fills the browser window and resizes with it) gets to a certain value.
So far I have a listener for the viewport resize event which can check the new dimensions and execute code accordingly. My idea was to create two different views and swap them out on the panel in the if statements that check for width. Is there an easier, more efficient way to do this? I couldnt really find a way to change the layout on an existing panel once it has been created.
Any general advice on this would be much appreciated, I'm working in MVC
Here is my code for the viewport resize listener, so far I'm only trying to hide the two column panel if the width gets less than 500 and have it reappear if the width is greater than 500. I'm unsure of how I would bring in a new panel.
listeners: {
resize: function(panel, w, h) {
var viewport = panel.up(viewport);
var detailpanel = panel.down('#detailpanel');
var gridpanel = panel.down('#gridPanel');
gridpanel.setHeight(h-70);
detailpanel.setHeight(h-70);
if (w<500){
panel.hide();
}
else{
panel.setVisible('true');
}
}
},
I'm working with two panels which are side by side (using the column layout). I'm interested in having the panels switch to being one on top of the other when the viewport width (fills the browser window and resizes with it) gets to a certain value.
So far I have a listener for the viewport resize event which can check the new dimensions and execute code accordingly. My idea was to create two different views and swap them out on the panel in the if statements that check for width. Is there an easier, more efficient way to do this? I couldnt really find a way to change the layout on an existing panel once it has been created.
Any general advice on this would be much appreciated, I'm working in MVC
Here is my code for the viewport resize listener, so far I'm only trying to hide the two column panel if the width gets less than 500 and have it reappear if the width is greater than 500. I'm unsure of how I would bring in a new panel.
listeners: {
resize: function(panel, w, h) {
var viewport = panel.up(viewport);
var detailpanel = panel.down('#detailpanel');
var gridpanel = panel.down('#gridPanel');
gridpanel.setHeight(h-70);
detailpanel.setHeight(h-70);
if (w<500){
panel.hide();
}
else{
panel.setVisible('true');
}
}
},