cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RussW
Advocate I
Advocate I

Using button strikethrough property in gallery with Teams Dataverse

I'm trying to find a way to have an end user experience such as the following:

 

  1. A gallery list of items displays
  2. User clicks one item in the list and the text gets crossed out
  3. User clicks again the same item, and the cross out/strike through disappears

Seems simple, but I'm running into a few road blocks.

 

What makes up what I've tried so far:

  • I started with a single button on a canvas
    • button.strikethrough = varStrike
    • button.onselect = Set(varStrike, If(varStrike,false,true))
    • essentially making varStrike a boolean data type variable
    • this by itself works as expected to strike through the text when clicked and then clear it when clicked again
    • I then ventured to try to duplicate this behavior in a gallery and keep the individual buttons isolated to only strike through those that were clicked
    • this is where I'm stuck

Where I'm at now:

  • Gallery is tied to a Teams Dataverse table
  • I've added a standard type button in the gallery so I can use the strikethrough property to easily toggle strike through true/false (i.e. button.strikethrough = varStrike)
  • I've tried variations of a column data type in my table between Yes/No and Choice, but am at a loss for how to patch that back to the table
  • my thought behind a yes/no column was to set them all to No and then toggle to Yes when the button is clicked giving me a value to use for other data validation purpose

 

What I need is a formula that will do these things:

  1. Toggle varStrike true/false
  2. Only affect the gallery item clicked
  3. Change the yes/no field/column in the table to match varStrike

This is the closest I've gotten, but I'm at a loss for tying together varStrike and the Yes/No column broken down:

 

Set(varRecord, ThisItem);

  • for efficiency as well as avoid gallery selection artifacts - tip found on Youtube

If(varRecord.'Module Course Name'

  • button text is set to 'Module Course Name' - to isolate to a given record

&& 'Strike Through (Curriculum timings)'.No

  • this is my Yes/No column 'Strike Through' in my table Curriculum timing; it's default state is No

&& varRecord.IsSelected,

  • this is my attempt to further isolate to a single record in the gallery

Patch('Curriculum timings', varRecord, {'Strike Through':true})); Set(varStrike, If(varStrike,false,true))

  • I can't quite get the format of this to update the option set value for 'Strike Through' AND toggle the varStrike, but what's happening with this is all of the buttons are crossing out and clearing

 

Any ideas of how I can accomplish this?

11 REPLIES 11
RussW
Advocate I
Advocate I

Thanks for getting back @TheRobRush.


I wasn't going to let this rest and was bound to figure it out! Thanks for the nudge in the right direction... just what I needed to come to a resolution.

 

This is what I ended up with that works like a charm:

 

App.Onstart

 

ClearCollect(colCurTime, 'Curriculum Timings')

 

Pulling it into a collection for app performance and then perhaps patch changes back to the source with a save, or navigation button.

 

Gallery1.Items

 

Filter(colCurTime, 'Module Course Name' <> "Empty")

 

Cleans up the list to just filled slots.

 

 

Gallery1.Button1.OnSelect

 

If(
ThisItem.IsSelected && ThisItem.'Cross Out',
Patch(
colCurTime,
ThisItem,
{'Cross Out': 'Cross Out (Curriculum timings)'.No}
),
Patch(
colCurTime,
ThisItem,
{'Cross Out': 'Cross Out (Curriculum timings)'.Yes}
)
)

 

 

This is one of the parts I was stuck. The AHA moment came when I looked at the Patch video on Microsoft's document site and saw how the formula was put together. The ThisItem record is what I was missing.

 

Gallery1.Button1.Strikethrough

 

If(ThisItem.'Cross Out', true, false)

 

I think I went overkill above when all I needed was to check against this since it is toggled by the button press.

 

All in all you both helped me come to this conclusion by guiding my idea along, so I appreciate your help.

 

Thank you!

TheRobRush
Super User
Super User

Exellent, I am glad your vision has come into existence haha 🙂

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,508)