cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jason_Hough
Level 8

Making a label visible on a single gallery cell only

All,

I really hope someone will know the answer to this.

 

I have a gallery which has peoples phone numbers on it. Each gallery row has a phone icon. When that button is pressed it will call the 'Name' on that gallery row - easy enough.

 

i want to be able to make a label VISIBLE only on the gallery row they have clicked on and , not the others unless they are clicked too. I also want it to stay visible even when another row has been selected.

 

So I have a phone Icon and I have enter this on the OnSelect :

If(Users_And_Numbers_Gallery.Selected.ID=ThisItem.ID, UpdateContext({VisibleOn : true}))

 

And on the label itself , I have just set the Visible as VisibleOn.

 

This does work but it makes all the labels visible on all the other gallery rows at the same time.

 

I need a way to only make Selected.ID = 1 , label visible only, or Selected.iD=2 , label visible only - dependent on which row the user clicks on.

 

I am finding this a bit of a callenge, thanks.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
JoeCitro
Level: Powered On

Re: Making a label visible on a single gallery cell only

I know its a year later but i stumbled on this post while trying to figure out the solution to my problem. I have found that sometimes great answers are months or years after the original post so I figured I would share.

 

Basically I have a text input field that i wanted the user to click and type in a value and then have an icon clicked to make it patch directly to the sharepoint list. However this icon needed to only be visible when the text input field was clicked and also only for that item in the gallery.

 

When the text input field is selected is sets a context variable to true. This is to make other icons hide when the field is clicked. The icon I'm using to patch the sharepoint list with the user input value has its visible set to ThisItem.IsSelected. The OnSelect for that icon also sets that context variable back to false so that the original icons become visible again.

 

The only thing I couldnt figure out was how to then make the "patching icon" hide again after the patch is complete. I ended up using a simple display mode function

 

If(ContextVariable,DisplayMode.Edit,DisplayMode.Disabled)

 

then I set the colors for the disabled mode to transparent. This means it is technically still there but since its behind one of the original icons it cant be interacted with.

 

I found this to work rather well for my app so hopefully it helps anyone else that may stumble accross this post in the future.

 

 

View solution in original post

9 REPLIES 9
Super User
Super User

Re: Making a label visible on a single gallery cell only

Hi!

 

To show the label only for the selected row is easy enough and you almost had it right.

 

Remove the code for the icon.Onselect. Instead, in the label's Visible, put only the formula from the Onselect: 

 

label.Visible:Users_And_Numbers_Gallery.Selected.ID=ThisItem.ID

 

This way the label is displayed only for the selected row. The reason the label is visible for all rows is the way you were doing it, one and only one variable controlls the visibility for every row.

 

Good luck!

 

 

Jason_Hough
Level 8

Re: Making a label visible on a single gallery cell only

Yes it shows the label and I understand why - but it removes the tag when another gallery icon is presed. I cannot keep the label on the gallery - this is the most improtant thing i need, as it keeps phone numbers in this gallery when an emergency happens - so we what the user to know which ones we have pressed (dialed). 

 

any extra help would be amazing. 

 

Jason 

 

Super User
Super User

Re: Making a label visible on a single gallery cell only

OK, I think I understand now. One questions though: does the click need to be saved until the next time the app is started, or is it enough to keep it for the current sesison?

 

If the status needs to be retained in between sessions yoiu would have to add a field in the database, for instance a bit field named Handled, with a default value of 0. When the user presses the call button you do a patch, setting the field to one (which means pressed): Patch(DBTable; ThisItem; {Handled:1}).

 

You then have a text field, an icon or something that you set the visibility to the field  Handled. Look at the screenshot of my app, the yellow semi-circle's visibility is controlled by a bit field.

 

Bitfieldflag.pngThe yellow semi-circke's visibility is controlled by a bit field in each record

 

If the click/phone call does NOT have to be kept in between sessions you can add a column to the table, and then instead of clicking an icon I would use a Check box for making the call/showing the call status. (I have tried many different ways to manipulate an added column in an OnSelecet-method, but so far I have had no luck).

 

In the screenshot below I have added two fields in the gallery's Items property by using AddColumns (you would only need to add one field, the DoSplit connected to the check box):

 

AddColumns(Filter('[dbo].[NyOrderRad]'; OrderhuvudId = gOrderhuvud_scrOo.Selected.Id);"DoSplit"; false;"Splitamount"; Antal)

 

These two extra fields are connected to a check box (DoSplit) and a text field (Antal) and are to the left och each row. Now, if you let the check box OnCheck-property fire the call, the check box will remain checked independently of other check boxes being clicked.

 

Checkboxadded.pngAdded a check box and a text field using AddColumns in the gallery's Items-property

 

This should work for you, but if you leave the screen or app and come back, all the check boxes will be unchecked; no data is persisted.

 

Hope this helps. If you need more help, please add a few screen shots of your app so it's easier to understand what you want to do.

 

Good luck!

 

 

 

bean
Level 8

Re: Making a label visible on a single gallery cell only

Hey,

 

From your initial post - this is my answer, which i was able to make from what @BitLord69 had mentioned.

I simply set the visible field of the button(where you could use what ever e.g. text label) to 

ThisItem.IsSelected

 sol.png

 

 

 

Super User
Super User

Re: Making a label visible on a single gallery cell only

That's a better way of writing it, thanks for the tip!

 

It does not seem to solve the problem completely though, since the button, or whatever control you have, will be invisible as soon as the user selects another row. There must be a way to keep the pressed status, hence my reply to have a field in the database. @bean Do you have any other good suggestions to accomplish that?

bean
Level 8

Re: Making a label visible on a single gallery cell only

@Jason_Hough @BitLord69

 

I've had a play around, and can't figure it out.. I might have another crack at it later. Keep me posted if you find a solution.

 

Good luck.

 

Sean

bean
Level 8

Re: Making a label visible on a single gallery cell only

The solution to this may be using a collection and data table rather than the gallery.. hmm

Highlighted
JoeCitro
Level: Powered On

Re: Making a label visible on a single gallery cell only

I know its a year later but i stumbled on this post while trying to figure out the solution to my problem. I have found that sometimes great answers are months or years after the original post so I figured I would share.

 

Basically I have a text input field that i wanted the user to click and type in a value and then have an icon clicked to make it patch directly to the sharepoint list. However this icon needed to only be visible when the text input field was clicked and also only for that item in the gallery.

 

When the text input field is selected is sets a context variable to true. This is to make other icons hide when the field is clicked. The icon I'm using to patch the sharepoint list with the user input value has its visible set to ThisItem.IsSelected. The OnSelect for that icon also sets that context variable back to false so that the original icons become visible again.

 

The only thing I couldnt figure out was how to then make the "patching icon" hide again after the patch is complete. I ended up using a simple display mode function

 

If(ContextVariable,DisplayMode.Edit,DisplayMode.Disabled)

 

then I set the colors for the disabled mode to transparent. This means it is technically still there but since its behind one of the original icons it cant be interacted with.

 

I found this to work rather well for my app so hopefully it helps anyone else that may stumble accross this post in the future.

 

 

View solution in original post

TopShelf-MSFT
Level 10

Re: Making a label visible on a single gallery cell only

Thank you for your help with this post @JoeCitro@bean and @BitLord69!

 

@TopShelf-MSFT

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (6,454)