I have 2 repeaters. One with 3 rows of names (this is where the row is getting added to) and one with over 100 names (this has the names that I select and add to the other repeater). I am performing a search by last name from the originating repeater and then selecting one of those names using a checkbox. When I click on my “assign selected patients” button a row should be added with that name to the repeater above. It works as long as the search only brings back one row. However, when the search brings back multiple names and I select one of the names (not the first in the list), it always adds a row with the name of the first name on the list. Would like to be able to add whatever names I am selecting via checkbox to the other repeater. Any suggestions?
I think you’ll need to upload your .rp file here in order for forum users to see exactly what’s going on with your code. There are many ways this could work or not…
In general, look again closely at your conditional logic–your IF conditions–to follow exactly how a row is determined to be selected and exactly what conditions must exist in order to copy a row to the second repeater. It is not clear from your description how you are performing your search; are you filtering the big repeater? How are you distinguishing between a row that meets the search criteria and a selected row from those row results? Does the first row in your search results somehow get automatically “selected”? …Etc.
Your source file will be worth 1000 x 1000 words!
Here is the way I usually do it. Note that this requires the column in this 100 row repeater to be unique. Assuming both columns were called name:
OnSelected Add rows 1 (setting name column in the small repeater to [[Item.name]] OnUnselected Delete rows where [[TargetItem.name == Item.name]]
If it takes more than one column to uniquely identify a row (e.g., you have 5 Smiths) make an “id” column (that you don’t display) where every row is unique and add that column value as well when you add the row. Then to delete it you’d just replace “id” for “name” in the OnUnselected above.
Attached is a sample of adding and deleting rows with checkboxes. It doesn’t matter if the first repeater is filtered.
repeater_add.rp (54.8 KB)
Hi again! I didn’t notice that you first select them, and then assign them with a button outside of the repeater.
This would be much easier if you filtered the second repeater rather than added/deleted rows. Do the following.
Get rid of all code in the checkbox
Make the data in your second repeater the same as in the first. Add the following filter on the second repeater in its OnLoad (not OnItemLoad) interaction
OnLoad Add filter to this where [[Item.isMarked == true]]
When you first run the prototype, the second repeater will show no rows because none of its rows are marked yet.
Now, when we click the button, we want it to go through all of the rows in the search repeater and mark and unmark rows in the second repeater according to whether the checkbox is selected. This calls for a listener.
Basically, a listener is something you force an event upon (like Move) and then that command’s corresponding event handler (e.g. OnMove) will execute for each row in the repeater. (If you google “axure repeater listener” you’ll see lots of examples using this technique.)
We’ll add a hotspot inside of the repeater to serve as a listener and give it this code (where the second repeater is called “toRepeater”)
That Set Items per Page command simply forces the filter in the second repeater to be re-evaluated.
Now, when the button outside of the repeater that does the transfer is clicked, simply move the hotspot by (0.0) to fire off its OnMove event.
Updated file: repeater_add_2.rp (59.7 KB)
This helps…thank you!