Repeater and passing a variable to item


#1

I am not sure why i cant track this answer down…
I have a repeater with Columns A, B, C
On my repeater i have the interaction
Loaded
Set Text
(RepeaterItem) to [[item.VariableName]]

Global VariableName=A

my question is - why does the variable “VariableName” provide an error, vs showing the data from Column A? If i change the line to [[item.A]] it works. i tried looking this one up and can not find info on it.

for kicks i also tried with a local variable setting LVAR1 = Variable value of VariableName

it still only works if i hard code it to Item.ACalendarWidget_v2.rp (63.1 KB)


#2

Hard to tell just what might be going on without seeing your .rp file. Could you upload it here? That will be the quickest, easiest and most reliable way for forum users to help you.

In the meantime, there are several things I notice in your description:

Typically, the Item Loaded event is used to set the text of widgets in the repeater, and not the Loaded event. The former is called for each row in the repeater datasheet, where “Item” refers to the current row and the “.ColumnName” is the value entered in the associated column cell for the current row
(e.g., Set Text of MyWidget to [[Item.A]] where “A” is the name of a datasheet column. The latter event, Loaded is called once for the entire repeater after all the rows’ Item Loaded events are called. But, perhaps this is your intent? To set the text of some widget in the repeater for each row to the same value, matching the value of a global variable named, “VariableName” --If that is the case, your action should be, Set Text of RepeaterItem to [[VariableName]].

A global variable is completely separate from the repeater, so not a property of “Item”. Unless you have a column in your repeater datasheet named “VariableName” your code would not work.

A local variable is not needed for this. You can directly refer to the value of a global variable in a value, formula or expression by wrapping the name of the global variable in double-brackets, e.g., [[OnLoadVariable]]. To help with this syntax, you can use a few mouse clicks to get it rather than type it in manually:

  1. Click the little “fx” icon at the right of a VALUE field in the INTERACTIONS panel.
  2. In the ensuing “Edit Value” dialog, click “Insert Variable or Function…”
  3. Spin open “Global Variables”
  4. Click one of the global variable names.
  5. Click OK.

You can learn more about variables and expressions in Axure here:

You can learn more about repeaters here:


#3

hey there -
thanks for responding back. i did upload the file. the idea is im trying to display a column from the repeater based on the variable. so…
If April display the April column, if January, display the January column


#4

This kinda hits on it with the conditional logic


#5

@jbzolla3, The file you uploaded does not quite match your screenshot. In your screenshot, you show that you’ve solved your issue and this would work to fill the repeater with the contents from the April column.

Looking back at your original post, you said,

Yes, that is how repeaters work.

Looking at the code for the repeater in your file, there are some errors. As I mentioned in previous reply,

  1. You have a Set Text action in the repeater’s Loaded event, which should only result in every cell in the repeater being set to the same value. Use the Item Loaded event, as in your screenshot.
    • In a repeater, the word, “Item” refers to a row in the repeater’s datasheet.
    • When the repeater loads and when the repeater is updated (e.g., applying a filter, adding/removing/updating rows, etc.) the Item Loaded event is fired, once for every row in your repeater. Then, the repeater’s Loaded event gets fired.
    • Apparently, Axure recognizes “Item” as a reference to each row in the Loaded event, but this is not a reliable method. If you ever “touch” the repeater (with an Add Row, Update Row, Filter action, etc.) the repeater would likely go blank.
  2. Your Set Text action uses this value: [[item.CurrentMonth]]
    • The syntax of using a “dot” or period char is a way to refer to a specific property of an object. So “item” would be the object and “CurrentMonth” would be a property of “item”.
    • In a repeater, the properties of “item” are the columns in the datasheet. So, in your example, you have four columns: “January”, “Feb”, “March”, and “April”. There is not a column named, “CurrentMonth” thus the expression, “[[item.CurrentMonth]]” would evaluate to null (blank, nothing.)
  3. Further compounding this problem, you have a global variable named “CurrentMonth” and a rectangle widget named “CurrentMonth”. This is not good practice, as it begs for errors.

Ultimately though, if you are trying to use a repeater for a monthly calendar, there are much better approaches. Just search for something like “calendar repeater” or “date repeater” in this forum. For example, here is one thread:


#6

thank you mbv66 - i was just trying an approach to see if i could make a variable call to a column. appreciate the help and you looking at the file.