Change background of a single row in a repeating group with an icon

Hello,

Thank you ahead of time to anyone who is taking the time to read this. I am full-stop unable to move forward with my app. I have a repeating group which displays a users “items”. Inside of this repeating group I have attached another Group with a HIDE icon inside of it. (First Icon at the line level in the attached image). The goal is that when this group/icon is clicked then that particular line item should grey out. I got it to work once, but when I SORT the items after the fact then the affected row is no longer greyed out, and instead the item that is in that position NOW is greyed out.

I have tried just about every variation of using State to get this to work, but I cannot. Is this impossible to achieve since I have a group created on the line of a repeating groups cells?

Hi there, @kyleadavis1989… if I understand your post correctly, I don’t think you can use a custom state to achieve the desired result (not to mention a custom state that is tied to the current cell’s index, which could explain an item that is in a previously greyed out item’s position being greyed out after a sort) because custom states lose their values when a page is refreshed.

The above being said, I think you need a field (let’s call the field hidden and give it a type of yes/no with a default value of no) in the item’s data type that you can key off of in order to determine if a particular item in the repeating group should be greyed out. So, a user clicks the hide icon for an item, you run a workflow that changes the hidden field for the item to yes, and then you have a conditional on the group to change the background to grey when the current cell’s item’s hidden field is yes.

Any of that make sense? Apologies if I misunderstood your post and missed the mark here, but I hope this helps, even if it’s just food for thought.

Best…
Mike

This makes complete sense, and is a simple strait-forward approach. I thank you so much!! I have no idea why I was performing mental gymnastics trying to achieve this using State!!

1 Like

Hey @kyleadavis1989

Glad you found a solution! am curious though - do you need the value to persist? I.e. when the user returns later do you want the same item to still be greyed out, or should all options be visible each time?

When the user returns to view this list I would like the item to still be greyed out. I have split the workflow so that they can toggle this on/off currently, but I am not sure if it will persist?

The ultimate goal is that each item in the row has a name, description, category and WEIGHT. When they click the hide button it goes grey AND the value of the weight is set to = null. This is so that thee weight of that item does not add into the calculation of the total weight of all items in that category (which i display in a chart). How can I get the original value of the weight to return when I unhide the item? This is another bridge I will need to cross since I have no idea lol.


I assumed you wanted it to persist, which is why I suggested using a field instead of a custom state. So, yes, it should persist with your current setup.

With regard to getting the original value of the weight to return when an item is unhidden, could you consider not nulling out the weight in the first place? Now that you have the hidden field, could you key off of that field when doing the calculation of the total weight? In other words, only add up the weights of items where the hidden field is no. I don’t know if it would be confusing for users to still see the weights associated with hidden items, but it could be easily explained that hidden items are not included in the weight calculation. Just a thought.

1 Like

And you could just set the weight text conditional to “if hidden is true then set text to null / 0” rather than actually nulling it in the database

1 Like

This is great, thank you BOTH for your assistance. I am certain I am asking too much but I will ask in case you have the time. Each of my items is assigned a Category. I have hard coded each category into the above chart that I made. I am trying to add and display the sum of each items weight within a specific category. However, I am only able to display the total sum of ALL of the items. Are you aware of a way to filter out items from wrong category? Or how to include only items from a certain category?

Well, at a high level and without knowing exactly how you have things set up, I would be using an option set for my categories, and the chart could be a repeating group that displays all of the categories from the option set. Then, the weights could be something like the sum of the current user’s items filtered by non-hidden items that have the current cell’s category. Or maybe the chart could be items grouped by category with a sum aggregation on the weight field… I would have to build it out to know which way I would actually go.

hmm is there any chance you would be able to elaborate on that a little bit?
Currently I have my database set up to have User with with a list of Weights. Each time an item is added to the User it will capture that weight of that item and add it to the list. It will also capture the Items CatOption which is the options set that they choose from.


I also set up a separate table to capture all of the items weights and category options for some reason

Currently I am able to display the SUM of all of the weights from the list of weights in a cell but I cannot figure out how to filter out for the specific Categories for the life of me. Here are those screen shots



Snip20210401_11

@kyleadavis1989 I’d have some reservations about the way you have set up your database. Notwithstanding I do not entirely know your use case / goal with for the app. But intuitively I would have associated the “weights” as a field within the “items” table, rather than separately. Also I do not follow why “CatOptions” and “weights” are being stored in the User table. Surely both of those should be associated to the “item” table.

If the “item” tables has the following fields: user, category, weight. Then you can create your summary table by category as per this demo I put together.

Rob, thank you a ton. I was able to get this to work by comparing with your code. I really appreciate you taking the time to solve my problem!!!

1 Like

That’s awesome, Kyle! Glad it helped :slightly_smiling_face:

This topic was automatically closed after 70 days. New replies are no longer allowed.