Adding hours in a new row of a Repeater


#1

Can someone help me how I can sum up a total of hours, when I’m adding a next row to my repeater?

In the first row, it seems ok, if I fill in some hours, you’ll see a total right below. But when I’m adding a next row, the total disappears.

Does anyone know how to fix that?

AddingHours.rp (97.0 KB)


#2

Hey there!

A really important thing to remember about repeaters is that any changes to the repeater (adding rows, sorting, updating) causes the entire repeater to refresh. So you’ll notice when you add a row, any data you had in the first row goes away.

This means when you work with a dynamic data set, you need to store all of that data in the repeater so that when it refreshes you can apply whatever data you had.

So, in your example, this means adding columns to your repeater to store the number of hours for the days. It also means you need to add an onItemLoad event to set the hours when they are stored.

Once the data’s all set, you can then add logic to the onItemLoad to set your total hours - because in this approach a change to every field resets the repeater, you['ll need to “Reset” the total hours on the first item and then add the hours in. You can see an example of this in the attached file.

There’s one drawback here - because the updates fire on lost focus, trying to tab through the fields doesn’t work. As soon as you tab and the field loses focus, the repeater refreshes and the current field loses focus. The numbers will all update, but it won’t tab to the next field.

AddingHours.rp (100.4 KB)


Adding a row in the middle of a repeater
#3

Hi Axure Fu Master,

Thanks so much for your explanation and fixing this problem of adding hours. I couldn’t find anything about it searching the web. The use of the tab is a pity, but I think it is more important that the addition continues in the next rows.


closed #4

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