Dynamically varying repeater item sizes based on content


#1

Hi folks,

Is it possible to dynamically vary the sizes of the individual repeater items (a simple box) based on the content inside the item (just some dynamic text)? I’m able to do it with predefined repeater data but I’m not able to do it with repeater data that is added dynamically (for instance added using the add row function).

Whenever I try to do this, ‘Fit to content’ seems to go for a toss and the width gets reset to the default width in the repeater definition for all repeater items.

Thanks!
-Mani B


#2

If you are trying to set the width of a widget based on content–like the width of a text string in a proportional font–it won’t work. The “Fit to Content” applies to the repeater cell, not individual widgets in that repeater cell. In other words, the “content” to which the cell is being fit is the collective dimensions of all visible widgets in that cell.

In a widget’s Style pane you can click a button to Fit to Width or Fit to Height based on the text value. However, this applies only to the default text value and not to ongoing–dynamic–text value. This applies whether a widget is in a repeater or not.

Years ago I posted this example with a few different methods to dynamically resize a text widget in a repeater:

This recent post from @Jorkin describes a method to change the width of a widget programmatically based on text content. I haven’t tried it out yet but looks promising.


#3

This is very helpful my friend. I tried @Jorkin 's solution and it seems to work perfectly. Thank you very much as always!


closed #4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.