Prepending the Flex Repeater Instances

Hi,

When adding instances in Flex Repeater, I need to add those instances in descending order. In other words, when new Flex instances are added, they should be placed above the previously added instances. Are there any possibilities ?

Thank you in advance.

Yes, there are possibilities.
However there are no possibilities without first knowing more details, like how you're creating the flex repeater instances.

As a random stab in the dark, try using:

assert isinstance(instances, list)
instances.insert(0, newInstance)

This will insert the new instance at the top of the list

direction: row(-column)-reverse

5 Likes

I'll translate what Victor said, because you might not speak the same language (he's French):

The repeater (and anything flex) can display things in reverse order. Just change the direction property, just like you can chose column and row, you can also chose column-reverse and row-reverse.

I strongly recommend you use this instead of inserting things anywhere in the instances property list.

2 Likes

I don't think the language is the issue here, it's more a universe of CSS experience between them :laughing: and hence the very short-hand comment :slight_smile:

PS. inserting things in the right order has its place if you want to insert them in a certain order. But yes, if all that's wanted is to reverse the existing order, then flex reverse is far cheaper (I rarely use this so didn't even think of it)

1 Like

nah i just woke up xd

2 Likes

It can behave... funkily.

? it's a(n ordered) list (a list is ordered by definition), so there shouldn't be anything funky about it

Try repeating a text input and inserting/deleting instances at arbitrary positions.

If the flex repeater hasn't changed significantly since 1.17, you'll get surprises.

1 Like

I don't understand. I know there has always been an issue when rearranging items in a list using the mouse (namely that you end up with two items with the same item index, and if you don't open another View and then go back to your View, it'll duplicate the data in one of them to the other - very annoying), but if you're creating this via script, I don't see any way that this could stuff up

I had to build a page where users can create parameterized objects, with an arbitrary number of parameters. I spent a good amount of time on this, and from what I've observed it seems that the repeated objects themselves are not rebuilt when you change the items in the list.

Let's say the repeated view contains a text input, which value is bidirectionally bound to an input/output 'value' parameter, so that you can gather the input from the repeater.
If you add an instance in the middle of your list, this new instance will get the value of the instance that was previously at this index. Same thing if you delete an instance from the middle, the deleted instance's value will be passed to the instance that's now at this index.

1 Like

Oh, I see what you mean... very dodgy! I'll package up my test for dev

Actually no, I just had a typo. It's working for me... maybe I don't understand quite what you mean

Text Input Repeater.zip (10.6 KB)

Can't try this now, but maybe things have changed since 8.1.17, which is the version I had to use for this project.