Select all in a Repeater Table


#1

Has anyone been able to create a Select All function of a repeater table? I have a table widget that I put together using Repeater, I have single select of row items working and sorting working but I haven’t been able to find any explanations of how to get a Select All feature working. So any help would be appreciated.


#2

For this kind of thing, there are 2 basic approaches I’m aware of

  1. Listener Event
  • For whatever actions you have to select your row, copy them to an unused event of a widget in your repeater. For example, if you have a “Select” button (say it’s named “r_Select”) with your actions assigned to Click or Tap, you could copy these actions to the button’s Moved event.
  • Then, for your “Select All” button (outside the repeater) you’d have an action to “Move r_Select by (0, 0)” --thus resulting in no actual movement, but triggering the Moved event of r_Select.
  • Whenever you call an action from outside a repeater of a widget inside a repeater, every row’s instance of that widget will get called, in rapid succession from first row to last row. So, if you have 10 rows then all 10 r_Select buttons would fire their Moved event, thus selecting all rows.
  • Improvements:
    • I’ve found it is usually better to keep your code on one event–in your case, the “select this row” action(s) likely assigned to Click or Tap. Rather than copy and paste actions to Moved (or Rotated or any otherwise unused event for any widget in the repeater) you can assign a Fire Event action to Moved, like, “Fire Event Click or Tap of This”. Doing it this way means you only have one place to maintain your “select” actions and not two or more.
    • Likewise, I prefer to use the Fire Event on the “Select All” button, as in, “Fire Event Moved of r_Select” instead of “Move r_Select by (0, 0)” as it makes it more obvious something special is going on.
  • There are many detailed examples of how to do this in this forum, just search for “repeater listener method” …and you’ll see that forum user josephxbrick is the master on this topic.
  1. Datasheet Column
  • This is my recommended approach, especially for your case. To me, it feels more official and less of a hack. Basically, you can control anything in your repeater via its column values and Item Loaded event. The main benefit for me is things like selection states get preserved when the repeater is changed–like adding, deleting, updating, sorting, filtering.
  • Create a column to store a value for the row’s selected state. For example, “true” or “false”, “1” or “0” …or better yet, “true” or anything else including blank (so by default, leaving this column blank will result in an unselected row.) Let’s say you name this column “RowSelect”
  • Create a conditional case in the repeater’s Item Loaded event like this:
    If [[Item.RowSelect]] equals "true"
    Set Selected of RowBackground to "true"
    (assuming this is how a row is shown as “selected”; insert your real action(s) here)
  • Again, let’s say you have a button, “r_Select” in your repeater cell. It’s Click or Tap event would then look like,
    Update Rows MyRepeater set RowSelect to "true" for This
  • For the “Select All” button, use something like this,
    Mark Rows MyRepeater all rows
    Update Rows MyRepeater set RowSelect to "true" for marked rows
    Unmark Rows MyRepeater all rows
  • You can set up all sorts of rules to define which rows to select, based on datasheet values or intrinsic row properties. For example, all rows that have negative values in a column, all rows with names that start with ‘A’, only rows with missing values, only even numbered rows, etc.
  • Here is a recent thread where I posted an example of this approach:
    Persist Repeater cell / row content when adding a new row

#3

Thank you, I’ll have to give this a try and see if I can get it to work. Do you have a Youtube channel or something? I’ve noticed your feedback on a number of posts with really high end advice. When I went to Skill Share for some courses it was kind of lacking and too beginner level. I’m really interested in the high fidelity interactions.