Find the Index of a newly created row in a Repeater

repeater-widget

#1

I have a repeater with 15 rows. It is sorted by Customer Number.
The user can create a new row after they enter data for each field. I know how to get it to do this.

BUT
When I create the new row, I want to be able to highlight that new row in the repeater, to show the row that was just created. Because the repeater is sorted, that new row might be anywhere.

I could have a highlight bar that is hidden in the repeater that is then unhidden, but I don’t know how to unhide the right one when the user clicks an outside button.

Since I know how tall each row is, if I could figure out what the index of the new row is I could move a hidden highlight bar that is outside the repeater to that y position and unhide it.

I thought I could have a hidden row with blank data, and when the NEW button it clicked it would populate it with a unique number (always adding 1 to the previous number for example to make sure it’s unique), but I can’t figure out how to find the index of a row based on that new number.

I have no idea how to get around this, or even if Axure has a way…

My simplified example below shows how I would like it to work, but in this case when you click NEW it uses a specific Customer Number so I know what row it will be in.

I hope this makes sense. I really appreciate any help.

https://gj9dbb.axshare.com


#2

I recommend adding a new column to your repeater dataset and using a conditional case in the repeater’s Item Loaded event to control this behavior.

You can name the new column anything, e.g., “NewRow”, and whenever you use the Add Row to create a new row item, set the NewRow column value to “true”. This would allow you to target just this one row (or, if multiple new rows can be added at once, you can target all “new” rows together) with a rule of [[Item.NewRow == "true"]] --which would also work in an Update Rows action.

In Item Loaded add a case like,
If [[Item.NewRow]] equals "true"
Show MyHighlightBar

If you want to access the index of this new row for later use, then you could add an action in this conditional case to set the value of a global variable or the text of any widget, e.g.,
Set Variable Value OnLoadVariable to [[Item.index]]

In your demo the blue highlight is shown briefly then disappears. In my method above, you can achieve this by using the highlight widget’s Shown event:
Shown
Wait 1000 ms
‘Update Rows This, set NewRow to “false”’

  • This should ensure that all rows will automatically (after 1000 ms) be “not new”
  • You could also enforce this by marking all rows, update all marked rows as 'NewRow to “false” ’ then unmarking all rows.

#3

Thank you for the response… It’s going to take me a bit to figure out how to use your suggestion in my actual prototype, but I think you are on to something…
One problem with setting the variable to [[Item.index]] is that as soon as you re-sort the table, that index number isn’t useful… but, I really only need it to show right after the row is created. I can then change the value of the NewRow column to False… Hmmm
I’ll let you know how I fare.


#4

Thank you for the response… It’s going to take me a bit to figure out how to use your suggestion in my actual prototype, but I think you are on to something…
One problem with setting the variable to [[Item.index]] is that as soon as you re-sort the table, that index number isn’t useful… but, I really only need it to show right after the row is created. I can then change the value of the NewRow column to False… Hmmm
I’ll let you know how I fare.


#5

Hi there - my solution to this is to create a unique timestamp for new record using [[Now.getTime()]] and setting a variable varTime at the same time. Then look for the match OnItemLoad. No matter how the repeater is sorted it will always highlight the ‘latest’ entry with the blue box. To my moderate surprise - works with multiple entry additions too. I thought a few milliseconds may fly by in-between row entries.

Here you go:
https://zcx41a.axshare.com/

Axure 10 file I’m afraid - Cheers - M

use_nowgettime_to_highlight.rp (62.2 KB)


#6

Oooh, that’s an interesting concept! I like that. I’ll have to try it. It’s very creative. Thanks!