Mark row add to markedRowCount, unmark row remove from markedRowCount

For some reason I am not able to get this to work. I need a count of marked rows in a repeater. Count starts at 0 if there are no marked rows. If row gets marked the variable “markedRowCount” increments by 1 and shows updated value on screen. Likewise if a row becomes unmarked, the variable “markedRowCount” decrements by 1 and shows on screen. Count can go no lower than 0. On some tries I have gotten a “negative” count - that should not happen. The attached file shows a negative number and I don’t see why.

I think the issue is because I am not performing an action to mark the row, such as clicking a button or hotspot for the row. The row is becoming marked based on a numerical value for the row derived from values in cells of the row. If the values for a row total are less than 100, mark the row. If the the values equal 100 then unmark the row.

Here is an example file I have been trying to get to work:
ShowMarkedRepeaterRows_v1.rp (143.3 KB)

Hi!

You are setting this variable in OnItemLoad. OnItemLoad executes for each row in the repeater. So for each row that has a total percent less than 100, it is subtracting 1 from your variable. (There is no logic that checks whether or not the row is marked.)

You are also incrementing/decrementing this variable in one of your buttons.

How do I create logic to determine if a row is marked? I really appreciate you letting me know what I am doing wrong, however do you have an example of what I would do to determine if a row is marked and update the count as needed, or could you make changes to the file I uploaded? As I stated, I am not sure what to do if I am not clicking a button or hot spot to mark a row.

Hi!

In OnItemLoad (or in any event handler whose widget lives in the repeater row) you can use [[Item.isMarked]]. Note that marking a row does not cause OnItemLoad to run.

I would remove the increment/decrement code from OnItemLoad, and add it to the button you are using to mark and unmark rows. To avoid extra clicks, I’d make your buttons look like this:

OnClick  (to mark the row)
  If [[Item.isMarked]] is equal to false
    Mark row This
 
OnClick  (to unmark the row)
  If [[Item.isMarked]] is equal to true
    Unmark row This

I am not using a button to mark/un-mark rows, as it were. The rows are being denoted as “marked” if the total value of % cells is less than 100, and they are being denoted as “unmarked” if the total value of the % cells is 100. Your remark makes very good sense, if I was using an action to mark/un-mark a row. Unfortunately that is not the case here.

Can someone please help here. I don’t understand why the repeater functionality works contrary to how it would work with an actual action to mark/unmark the row. In the case of this issue, it is as if the “marking/unmarking” is a ‘soft’ action, because there is no actual performing of an actual action on the row - but the row is being acted upon by a process outside of the repeater - gathering the sum of the % cells.

Yes, that’s basically correct. I think of it as a state without an event listener. As @josephxbrick notes, you can use the .isMarked property, but that still doesn’t achieve what you need: an event listener or just “event” in Axure terminology. There isn’t a reliable way (that I know) to use logic of “if row X is marked, do Y” --but, you can use a real or “hard” event, such as a selection or visibility state change, and simply do that whenever you mark/unmark rows, or use that event to perform the marking/unmarking.

Your repeater has a lot going on and is difficult to tell just what’s what and all you are trying to achieve here (e.g., it is not good practice to use numerical operators in your widget names, such as ‘+’ and ‘|’). See this simplified example for a demonstration of counting marked rows.

count marked rows.rp (61.1 KB)

Notes:

  • The counter is initialized to zero whenever the repeater is loaded/touched --see Case 0 of the repeater’s OnItemLoad event. This is important.
  • The logic for determining if a row is marked selects a widget (the rectangle widget in the repeater, named “rowValue”
  • The Selected event for “rowValue” in turn marks the row and increments the counter
  • The Unselected event likewise unmarks the row and decrements the counter
  • Since the only way to mark a row here is based on the “summed value” of the repeater’s column values, this all works. So if you needed to mark/unmark a row (e.g., a button external to repeater) the “proper” way to do so would be to change that row’s value to less than 100 (by updating the Col1 or Col2 value for that row.) You could also set a particular row’s “rowValue” widget to “Selected” directly to override the “summed value” logic. If you were to simply mark a row externally, the selection state would not be shown and the counter would not be updated.
1 Like

Thank You mbc66. This gives me a fighting chance to figure out what I did wrong and to move forward. After looking at your code I see where I can make changes in what I am doing. I REALLY appreciate your thoughtfulness, knowledge of Axure processes and time you have taken to respond. THANK YOU, THANK YOU!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.