Remembering Collapse states > store array var to db

I have many collapse regions on the page and i want to store their state in the Members table in column m_collapse_state. Probably as an array. I COULD do it with a separate joint table but i want to learn arrays :slight_smile:

Basically i will assume they are open unless Item exists in array then close it.
When collapse/button is pressed, Update array and save in table.

I just can’t figure the update db logic yet.

I created an Array element, added click event to populate it . Got this far. How to save to db?
I tried adding an update server action but cannot choose the Array variable, need to pass that to the action somehow.

any ideas?

thanks

Hard to be too specific based on your info but basically you may be able to do what you want by

Define your server action to save the settings with the array passed as a GET parameter

Then in app connect, make a server connection and set it to No Auto Load and link your array in the parameter box as detailed below.

Then, in your dynamic event linked to collapse, load the server connection to save the details

1 Like

Yupp that worked! :slight_smile: thanks!

I was trying to do it with sessions but couldn’t figure out how the server sessions where related to the app connect sessions.

They are different, in app connect, session refers to browser sessions, in server connect they are server session, yes it is confusing

There is a feature request to allow access to server sessions from app connect if you want to vote for it

One more thing.

The Array var is now stored in the Db Correctly initially.

I then bind the Array Var to the db value. So it has a default value. thats working too.

However now the ADD Unqiue doesn’t work… doesn’t seem to recognize that the array var already has values pulled from the db

Nevermind figured it out, Had to use Split value. :slight_smile: man so many things to discover :slight_smile:

1 Like