PDA

View Full Version : Change Anchor '100% 50%' to '100% 100%' at runtime?



FlyFoxUK
13 Feb 2010, 9:10 AM
I have a grid rendered with config anchor: '100% 50%'. On pressing a button, I'd like to expand this grid to be '100% 100%'.

I have tried:


myGrid.anchor = '100% 100%';
myGrid.doLayout();
myPlaceHolder.doLayout();


but this does not work. Anyone got any pointers on how I can achieve this dynamic change to the grid layout at runtime?

Many thanks

FF.

Animal
13 Feb 2010, 9:53 AM
No, it's only read on fist render. I don't like this, and suggested that it be read on resize...

FlyFoxUK
13 Feb 2010, 10:00 AM
Animal - thanks - so I would have to destroy the grid and re-create it with the new anchor property to achieve this?

I note that myGrid.setHeight(<value in px>) works OK but it not quite what I want to achieve, given the browser window could subsequently be resized and the grid no longer be anchored.

Cheers

FF.

Animal
13 Feb 2010, 11:43 PM
What layout effect are you after? Could be that one of the Box layouts might work better.

FlyFoxUK
23 Feb 2010, 1:37 AM
For others who may want to achieve the same effect, I have success using this:



myGrid.anchor = '100% 100%'; // set anchor as reqd
delete myGrid.anchorSpec; // remove the grid's anchor cache
myPlaceholder.doLayout(); // forces the grid anchor to be recalculated


FF.

Animal
23 Feb 2010, 1:53 AM
I think this should be documented somehow.

madirishman
11 Mar 2010, 10:52 AM
For others who may want to achieve the same effect, I have success using this:



myGrid.anchor = '100% 100%'; // set anchor as reqd
delete myGrid.anchorSpec; // remove the grid's anchor cache
myPlaceholder.doLayout(); // forces the grid anchor to be recalculated
FF.

Works like a charm! Thanks!!

Carina
13 Aug 2011, 2:40 PM
hi,

I'm sorry if this bothers anyone since it doesn't have anything to do with 3.x. But I came here via the search function and it seems to be the best thread about this issue. So if anyone else has this problem, I want to save them the time to look for a solution that works with 4.x.

This works for me:

item.anchor = "100% 100%";
item.ownerCt.layout.configureItem(item);
item.ownerCt.doLayout();


Which is a little nicer/less of a hack than the 3.x solution but I couldn't find any documentation about this.