Normally i might do things like “on page load, set state of Group A to ‘selected’ only when blah blah blah condition is true”
But this time, the group is inside a RG. Now when i go to build a workflow that says "on page load, set state of … but now “Group A” does not appear as an option. Why is this? how do i set the state of a group that is inside in a RG? Is it possible?
Just out of curiosity i would like to know
why you would like to set state on group instead of page…
I read somewhere its always better set state on page in some tutorial
I am quite new to set states, Just asking
I have 30 groups in the RG and when the page loads i need the groups to be set to a state selected = yes (only if the database thing for that cell is ‘completed today = yes’) so i can make the group appear and function differently depending on whether it meets that condition/state or not.
I.e., some groups will appear green and some will not depending on if their cells “completed to day” = yes which i plan to have happen via setting the state
A custom state inside an RG is considered to be in a different context to elements outside of it, the reason being that the states are set on a per-cell basis just like an array so you’d need to have the context of the particular cell to set it. It’s notorious that you can’t set states inside an RG from outside. However you can use @vini_brito 's plug-ins Orchestra and Satellite to do this. Check them out, I’ve found them really useful.
Surely theres a way without plugins
I just want certain cells group to appear green (on page load) if their database thing = yes
I think you’d be better using conditionals to do that, eg make groups visible or invisible depending on the value in the DB. The groups inside the RG will have context of the current cell (or parent group’s value) so you’ll be able to set them in there.
Conditionals can’t set states though??
No, on the individual groups inside the RG that you want to appear differently depending on the value in the DB.
Yeah i understand that i can do conditionals like “when this groups ‘completed today’ is ‘yes’ make the background colour green” but it’s not as simple as that because i also need to make it so that clicking it will modify the database differently when it is clicked (+1 or -1 to a daily streak)
The way things are currently is that when the groups is pressed, it sets the groups state (named ‘selected’) to ‘yes’ and then modifies the daily streak by adding 1 and modifies 'completed today" to “yes”. i have an opposite workflow that subtracts 1 from the database and sets the groups state to “no” (which is how i remove the green border with a conditional).
The problem is… when you reload the page the streak is still increase one (as it should because its getting it from the DB) but now the set state ‘selected’ of all the group is reset to ‘no’ and now you can press them again and it will add to the score again which is not cool because when the page reloads, you should NOT be able to add +1 if it has already been done today.
OK, you can still have your custom state on the group inside the RG, however you can’t set an initial value to a custom state for the group in every cell/record from outside eg on page load (not without a plug-in anyway). What I would do (and I was only doing something similar earlier today) is to have a custom state inside the group in the RG and set it’s default value (in the element inspector) to a pre-set neutral value, eg if it’s a number set it to zero or -10000 or something you can rely on to know that it’s not yet been touched by any selection by the user. When the user clicks to increase or decrease, in the workflow you can check whether the custom state is still in it’s neutral state, if it is you can have an action to set an initial value to it eg pull it from a DB field in the current cell etc. Then you can process as normal.
Hope that gives you some pointers anyway.
There are always multiple ways to solve an issue. If you are adamant about adding a set state inside a repeating group on ‘page is loaded’. Try putting it in a reusable element, then drop it in the repeating group. Inside the reusable element you should be able to set a state on ‘page is loaded’. I haven’t tested the theory, but it should work….in theory.
Anyways, thought I would throw my two cents in to see if it could help. Hope that helps.
since the cell will act differently based on the current thing in the BD is yes, why don’t you control the look using conditionals on the cell, and control behavior using conditionals on the workflow? No need for states.
Cell Look: “when this groups ‘completed today’ is ‘yes’ make the background colour green” like you said can take care of the look.
Cell Behaviour: two workflows; one runs when the current cell is clicked and this groups ‘completed today’ is ‘yes’. Second workflow runs when the current cell is clicked and this groups ‘completed today’ is ‘no’.
This is true but there are lots of other little things that are relying on the front end (set states) for information, which i like because it makes things faster, but of course it doesn’t stick around after page reloads haha
Hey, what are you referring to when you say “it” ?
Are you saying to put the RG or the group in each cell into a reusable element?
Ok so i have put the group inside a reusable element and have put that reusable element in the RG cell and i am trying to (on the reusable element) make it set the state on page load but i can’t figure out how to tell it to do that only when current cell’s x = such and such because it doesn’t know its in a cell of a RG when you are build a workflow from within the reusable element’s page.
And when i try to do it instead on the main page level (i.e., the “when page is loaded”) is still does not give an option to say “only when current cell …”
I’m going to try this method now