Is there any way to get the height of each repeater item text field

repeater-widget

#1

I have been trying to do something like a messaging page whereby when users enter their message, it will resize and re-position the container wrapping each repeater items. However, currently i am using javascript to get the height. but it seems that all the message containers are resized to the same height. I don’t know how to fix this. I also put a wait 1 s before and after the javascript. I suspect it is because of the wait. However, previously when i didn’t use the wait, it doesn’t get the height at all.


#2

You should be able query the properties of your container widget to obtain the current size, for instance, [[This.height]] and using a local variable to point to a widget, [[LVAR1.height]].

If you have a widget set to “Fit to Text Height” then its height will be set when it is loaded to fit the existing text. However, this is done once only. So, if it is in a repeater, it would/should be sized properly to fit text, for example from your repeater dataset. However, if you try to later change that text, its height will not change. This means it will be assigned its original height–the height of the widget in your repeater (in the Axure editor.) Frustrating, but that is how it works …or doesn’t work depending on your perspective.

If you are using javascript to calculate the font height and how much height you would need for a container with N text lines, you should do this from outside the repeater. There is no way to add meaningful delays to the item loading routine–the series of rows will be loaded as fast as possible, so if you try to add a Wait action in the OnItemLoad event, it would be processed after many/all rows have already been added, so would likely not apply to the row you intend–most likely the last row only if at all. In general, you should put in a bit of delay to allow javascript data to be registered in Axure and a delay to send/process any javascript calls to change properties or page elements. But this delay should be more like 50 to 100 ms. If you start with a delay of 1000 ms and it works, try 100 ms, then if needed, bump it up by 100 ms until it is stable.

This thread might help you with dynamically setting widget heights to fit text: