Repeater, empty state

Hi,

I’m building a repeater where the user can add rows to it. But I would want something to happen when the repeater is empty.

So, the user adds rows, then deletes all rows. But I don’t seem to figure out how to know if it’s empty.

I’ve tried different things, “If repeater.VisibleItemCount is less than 1”, “if repeater.VisibleItemCount = null” etc. Also with other variables like dataCount and itemCount and it does not work.

Anyone who could help me with this, and I’d be very grateful.

Thanks,

The syntax you noted is associated with a repeater item. I.e. item.repeater.visibleItemCount. However, when you have an empty repeater there are no items.

There may a better way to do this, but what I end up doing is associating the repeater widget with an LVAR and then using LVAR1.itemCount or LVAR1.visibleItem count, etc on move of a widget OUTSIDE of the repeater. This way I can still fire the logic even if there are no rows.

I then use that same move action on load of a row and also on delete of a row. Have a look at the attached sample and let me know if you have any questions. Also curious if anyone else has a more elegant solution.

emptyRepeater.rp (48.0 KB)

1 Like

Thank you s much for your reply.

I still don’t make it work though. I’ve tried putting the logic outside of the repeater, and then fire even on load. It does work, but problem is that the number never goes to zero.

I have it writing out the LVAR1.visibleItemCount every time it fires, and as I add and remove numbers the written number updates properly, except when I delete the last row. Then it stays on 1 instead of going to 0.

I’m guessing you only have it on itemLoad? You need to add that same action to whatever deletes rows, too. When the data set is empty onItemLoad will never fire.

I didn’t highlight this very well, but if you look at the example file inside of the repeater, on my delete button I also added my move action.

If you can share your file I can be more specific :slight_smile:

EDIT - I forgot save a few changes… the original file was missing this. Here’s a version showing what i’m taking about - look at the action on the delete icon inside of the repeater…emptyRepeater.rp (48.0 KB)

1 Like

Ah ok, yes I get it now! I got it to work. Unfortunately I have a lot of delete-buttons, but at least it is working.

Thank you so much for the help!

Yeah, it’d be nice if there was some sort of “isEmpty” check for the repeater that fired independently of the itemLoad. I guess that’s a feature request…

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