I started making a demonstration of my approach and realized I didn’t really need filters. Determining duplicates can be done with the Update Rows action and same kind of rule used in a filter.
See the “check with button (2)” page in this updated .rp file
rowcheck.rp (188.0 KB)
Essentially my solution uses one datasheet column with one number–a kind of “numeric string”–to represent the states of all checkboxes in a row. It makes it much easier to compare two or more rows to see if they are duplicates–the same states for all checkboxes in those rows. The tradeoff is a bit more complicated string logic in the repeater’s Item Loaded event to set the selection state (checked, unchecked) for all the checkboxes. However, it is straightforward and the result is still less complex than your initial Item Loaded conditional cases.
Here is the datasheet for my repeater:
- I kept your “num” and “studyDescription” columns
- I collapsed the 9 “option” columns to one “options” column (with a 9-digit number where each digit represents the state of the corresponding checkbox; and all unchecked by default. To show them all checked by default, change the entry to “111111111”)
- I added a column, “duplicate” to track which rows match other rows
- I added a column, “ref” to track the current “reference row” where say row 1 is tested against all other rows, then row 2 is tested against all other rows, etc.
In the Item Loaded event, the “secret sauce” for setting the checkboxes uses a built-in method (function) named charAt() which extracts a single character from the string in the “options” column. You can find this function under the “String” category when you click on “Insert Variable or Function” in the fx “Edit Text” dialog:
Additionally, you can learn about all these built in functions by Googling them. For example, search for “javascript charAt()” …Or alternatively, whatever solution you are trying to do, like “javascript get single char from string”.
When a checkbox is clicked it can likewise set (change) its corresponding character in the options string. However, when a checkbox is in a repeater and tries to update the repeater based on its selection state things don’t work as you’d expect. I think it is a kind of conflict between the checkbox changing itself (unchecked to checked) and updating its own row in the repeater datasheet. So, I placed a hotspot in front of each checkbox that updates the rows only …then the Item Loaded event alone sets the checkbox. You can inspect the interaction code for the hotspots to see how this is done with the .substring() function.
In the repeater cell I removed your hotspots and hidden widgets. I added to temporary widgets to show the value of the “options” string and the “duplicate” value for each row. You can delete or hide these once you see how they work.
I hid your “check entries rows” and “check entries columns” buttons as they are not needed. I put the latter button and the “Add” button in a dynamic panel so they can be moved together when the repeater grows/shrinks–so they always appear below the repeater. To do this easily I also placed the repeater in a dynamic panel and use its Resized event to correctly place everything below it.
I removed all your global variables and replaced them with these:
-
referencerow : the current row being tested against, represented as its “options” string
-
checkCount : tracks the remaining number of rows to be tested
-
duplicateCount : tracks how many rows are duplicates of the reference row
To make things more efficient and flexible, I created a few “subroutine widgets” that can be repetitively called in recursive fashion–essentially once for each row in the repeater. These “subroutines” are dynamic panels with two blank states. When the state changes it performs its function. So, when the “Check entries” button is clicked, it initializes things then “calls” or fires the “Test Rows” subroutine. For good measure, it disables itself so it can’t be clicked again while the row tests are being processed.
-
Test Rows
- Sets the current reference row in the repeater
- Waits a tiny bit to ensure the repeater is updated before trying to update it again
- Finds and updates all duplicates to this row, if any
- The algorithm, or rule, for this is:
[[Item.options == referenceRow && Item.ref != 'true']]
- This highlights all rows matching the reference row but not the reference row itself. This is so there would be no rows highlighted if no duplicates. Otherwise, the reference row would be highlighted even if no duplicates found.
- In the repeater’s Item Loaded event when the Item.duplicate column value is greater than zero it updates the duplicateCount variable–for the current reference row only.
- Then fires “Cleanup Rows”
- Else if no more rows to be tested, it enables the “Check entries” button and finishes.
-
Cleanup Rows :
- If one or more duplicates are found, it then updates the reference row to mark it as a duplicate too
- It decrements the checkCount value
- It calls the “Test Rows” subroutine, so the next reference row can be tested
- If no duplicates found for the current reference row, it just moves on–no repeater changes needed