PDA

View Full Version : Get absolute position relative to container



zz9pa
3 Dec 2013, 2:13 AM
Is there anyway of getting the current relative position of a field within a panel ?
I've tried several functions - but they all seem to get confused of the panel is scrolled..

What I'm trying to do is take a form panel with its normal "form" layout and try to construct a new one based on it with an "absolute" layout so fields can be moved around..

tobiu
3 Dec 2013, 2:50 AM
take a look at:
http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.util.Positionable-method-getBox

you can call getBox() on each element (not class), so you need to figure out which element is the right one.

e.g.

panel.el.getBox()
panel.body.getBox()
field.inputEl.getBox()

zz9pa
4 Dec 2013, 6:58 AM
I dont think they take into account the scrolling - so if a control is halfway down the page, but you scroll it to the top - you get a small "Y" value (For example)

I ended up caching the values when the page is rendered - before any scrolling can take place -which seems to work