Repeater - Add Based on Marked Status and Item Value

Clicking the Object ID Item sets the row to marked. I want the “Add 2 Rows” button to work based on whether Object ID 100 and/or 200 (and eventually 300) is selected. If one or the other is selected, add the appropriate 100/200-level rows. If both are selected, add 100 level rows to Object100 (Box1) AND 200 level rows to Object200 (Box2).

I can’t, for the life of me, figure out how to get the 200-level rows to add with conditional logic. I’m absolutely stumped.

Please help.

-g

HeavyRepeater.rp (74.7 KB)

In your external “Add 2 Rows” button, you refer to widgets inside the repeater, which won’t work, because it would refer to all repeated instances, not just one–and there is no way to directly refer to a unique repeater cell without its index.

You need to add a widget inside the repeater to respond when its contents match a target. Or, add an event which would not otherwise be called, such as moving a widget by (0,0) or rotating it 0 degrees. The logic goes something like this:

Move widget in repeater. // the widget in every repeater row will get “moved” in succession, thus setting up a kind of for() loop, as in: (for each widget instance)
– On widget move, test the repeater index (or text in a widget, selected, marked, etc.)
---- If test returns true, do something

So, this is like shouting out a number and asking a line of people to call out their line position, and if it matches the number you said, they jump up, or turn around, or get out of line–whatever they are supposed to do.

Check out this fix: HeavyRepeater.rp (83.2 KB)

I copied your code from “Add 2 Rows” to the OnMove event of the ObjectIDItem widget in the repeater, and referred to the repeater column pointers instead of text in the widget --so, [[Item.ObjectIDItem]] instead of "text on ObjectIDItem". I also added a condition for “300” items, using your code from the “200” condition.

It looks like it works as you intended, but hopefully at least enough to help you move forward.

@mbc66-

Can I use any widget to make things happen, as long as it lives inside of the repeater? You helped with the “add 2 rows” option. However, there is an “add 3 rows” option and an “add 4 rows” option forthcoming. I’d like to avoid all of the conditional logic that would be required on ONE Item in the repeater.

Can I create 3 widgets INSIDE of the repeater (called, say, add2, add3 and add4 respectively) and have THEM do the same thing? I ask because I noticed that you put the OnMove interactions on the ObjectID Item.

Thanks.

-g

OK, well, it’s close. I thought it was working as I expected but there is just a small issue:

Rows should only get added to selected/marked Header rows. Right now, this will break it:

Click the 100 row to highlight it and then click it again to remove mark/highlighting. Now press Add 2 Rows (v2.). Even though the row is now unmarked, it still adds 2. I hope I’ll be able to figure it out!

Anyway, I’ll look into this. It’s definitely way better than what I had before!

Cheers.

-g

OK, sorry for the rapid-fire. I see that the 100-series header had a different Item.Marked condition, rather than looking at the Text on Widget of the Marked column.

It is working properly now. Likewise, I did see that I can add it to a totally independent widget, which will allow me to have different widgets for adding 2, 3, and 4 rows.

@mbc66 Once again - thank you kindly for the solution!

-g

1 Like

Yes, you can do that. You can create any number of widgets in a repeater and assign code to them. The widgets can also be hidden so they don’t affect any visuals or interactions. Keep in mind that it will likely be harder to track, find, debug and reuse code if you have lots of different widgets, versus assigning all the “control functions” to one widget.

For instance, you could also create a kind of “master function” with an empty dynamic panel (dp). Create a state for every operation (routine) you need, then set the dp to that state to trigger the routine. For example, you could have a dp named “Add Rows” with these states:

  • default
  • add 1
  • add 2
  • add 3
  • add 4

Then in the OnPanelStateChange event, create Case statements for each and paste in your interaction code. Include a “default” or “null” state as the first state and be sure to always reset the dp to the “default” state at the end of your Case statements. That will ensure the dp will actually change to the state you request.

To add two rows, you would just need a command like, “set Add Rows to ‘add 2’”.

Thanks - I’ll try the Dynamic Panel process when I go to add the 3 and 4 options.

My first attempt to use widgets inside of the repeater (for something else) has failed. I tried to mimic the row selection/marking already in place, but it selects every row… sigh

I’ll probably be posting something soon. Man, it’s been a long Friday.

Cheers.

-g

From within a repeater, you can mark the current row by selecting the “This” radio option.

For selection or other things in which you need to identify a current row some format of setting the value via updating rows works best. Or you can use [[This.value]] or compare [[Item.index]] to a count.