Setting the Value of an Indexed Array when Element is Clicked

So I have an indexed array variable called show_help. It is an indexed array of booleans.

I can display a value with key 1020 with the syntax:
{{show_help.value.1020}}

When clicking on an element in my design I want to be able to:

  1. Set the value - I have tried show_help.value.1020.setValue(1) but this doesn’t work. What syntax should I be using?

  2. Toggle the value - What syntax would I use for that?

Thanks! :slight_smile:
Antony.

I’m wondering if anyone knows the answer to this… I’ve spent hours trying to work it out myself with no success…

@George or @Teodor do you know how to do this?

My app is at a bit of a standstill till I can work this out! :frowning:

Thanks in anticipation,
Antony.

What is this indexed array that you have? The setValue() method only works on components with that method and not on data.

I don’t think it is going to work the way you want, please explain what you are trying to achieve to us so that we can help you finding a better solution.

Hi @patrick…

Thanks for stepping in to help me… I appreciate it! :slight_smile:

I have several hundred items of help text that I need to be able to toggle. Each piece of help text is for a specific field in my data structure. I don’t want to create several hundred separate variables as they will be very hard to manage.

My app is multi-lingual, so each field is assigned a number, so for example, in my contacts table, first_name is 1000, last_name is 1010, etc. They are non contiguous for lots of important practical reasons.

So my planned implementation for toggling the help text is with a data structure in the database which is basically a non contiguous array of booleans. They are all set to 0 in the database, so like this:

show_help(item=1000, show_item=0)
show_help(item=1010, show_item=0)
...

I read them into a variable in my app called show_help with the assignment:

get_show_help.data.get_show_help.toKeyedObject(item, show_item)`

and from that I can read the binary values with the syntax:

show_help.value.1010

However since these are toggle variables, I also need to be able to assign to the boolean value of show_help.value.1010 and this is what I cannot work out how to do.

I hope that helps to explain!

Best wishes,
Antony.

At this moment it is not possible to set data properties with App Connect. You can create a custom control for your needs or use one of the other existing controls.

I think for you the array component could be a good solution. Just add the items that needs to show to the array using array1.addUniq(item) and array1.remove(item) to hide it again. Then checking if it should show the help you use array1.items.contains(1010).

Hey @patrick, that is a genius solution… thank you soooo much! :slight_smile: