cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
JoakimAndersson
Level: Powered On

Gallery.Selected changes in the backgorund because of sortbycolumns

Hello!

I have an issue I don’t know how to solve. The app I am creating is a services desk-like app with a ticket system.

I have a gallery with tickets containing various information. The user can click on a ticket for navigation to a summary screen with more detailed information. Here I use Gallery1.Selected.X to display the information I want. On this screen the user can patch various values of the ticket. This has worked as intended until I created a sortbycolumns expression on the initial Gallery1.

 

Let’s say I click the top ticket in the gallery, I am navigated to the summary screen, and I patch a value for the ticket. In the Gallery1 on the previous screen this newly patched ticket has dropped to the bottom of the gallery because of the sortbycolumns, this works as intended. What dont work as intended is that the Galley.Selected value still refers to the top item of the Gallery1 and not the originally clicked item (now at the bottom).

 

I hope somebody can understand this explanation and help me out. This seems weird to me. The Gallery.Selected shouldn’t change just because there sorting do.

 

Cheers,
Joakim   

  

  

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Gallery.Selected changes in the backgorund because of sortbycolumns

Hi @JoakimAndersson,

Do you mean that the result the Gallery1.Selected formula returned would be changed when you made changes for any record within your data source?

The user @aabrin has faced same issue with you, please check my response within the following thread:

https://powerusers.microsoft.com/t5/General-Discussion/Bug-Gallery-with-calculated-values-will-lose-...

 

When you patch a value for "Sortering" column of the selected ticket record, the result the AddColumns formula returned would be updated, so the Gallery items would be refreshed/updated. In default, the first item of the Gallery control would be selected.

If you want to not change the selected item within the Gallery control when you patch a value for any ticket record, please take a try with the following workaround:

Set the OnSelect property of the Gallery control or the Navigate icon ( ">") button within the Gallery control to following formula:

Set(CurrentSelectItem,ThisItem)

Set the Default property of the Gallery control to following formula:

CurrentSelectItem

Set the TemplateFill property of the Gallery control to following (Set a background color for the selected item to distinguish😞

If(ThisItem.ID=CurrentSelectItem.ID,RGBA( 255, 105, 180, 1 ),RGBA(0, 0, 0, 0))

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Super User
Super User

Re: Gallery.Selected changes in the backgorund because of sortbycolumns

What column are you sorting on?
JoakimAndersson
Level: Powered On

Re: Gallery.Selected changes in the backgorund because of sortbycolumns

Here is the code for the Gallery:

SortByColumns(
SortByColumns(
    SortByColumns(
        Filter(
            AddColumns(
                GarantiErsattning,
                "Namn",
                LookUp(
                    cashe_personuppgifter,
                    ID = GarantiErsattning[@PersonuppgiftsID],
                    Namn
                ),
                "Efternamn",
                LookUp(
                    cashe_personuppgifter,
                    ID = GarantiErsattning[@PersonuppgiftsID],
                    Efternamn
                ),
                "Sortering",
                LookUp(
                    cashe_flode,
                    ID = GarantiErsattning[@StatusID],
                    Sort
                )
            ),
            TI_sök_art.Text in Text(Artikelnummer),
            TI_sök_butik.Text in Text(Onskad_atgard) & Text(ArendeID),
            TI_sök_namn.Text in Text(Namn),
            TI_sök_efternamn.Text in Text(Efternamn),
            TI_sök_ärende.Text in Text(ArendeID),
            If(
                Checkbox_visa_avslutade.Value = false,
                "false",
                ""
            ) in Text(Avslutad)
            
            
        ),
        "Sortering",
        Ascending
    ),
    "Skapaddatum",
    Descending
), "Avslutad",
Ascending)

So when I patch a value in "Sortering" the order in the gallery changes, as it should. The issue is that the Gallery.Selected.X value changes too. 

 

i.e.

 

When I patch one value on my summary screen the order of the items in the gallery changes (which it should).
But at the same time the value for Gallery.Selected changes without me clicking in the gallery.

Im not sure I am explaining this all to well 🙂 Hope you understand.


 

JoakimAndersson
Level: Powered On

Re: Gallery.Selected changes in the backgorund because of sortbycolumns

Clarification:

 

If the sorting order of the gallery changes so does the value for Gallery.Selected on another screen, without me clicking on the gallery.

Community Support Team
Community Support Team

Re: Gallery.Selected changes in the backgorund because of sortbycolumns

Hi @JoakimAndersson,

Do you mean that the result the Gallery1.Selected formula returned would be changed when you made changes for any record within your data source?

The user @aabrin has faced same issue with you, please check my response within the following thread:

https://powerusers.microsoft.com/t5/General-Discussion/Bug-Gallery-with-calculated-values-will-lose-...

 

When you patch a value for "Sortering" column of the selected ticket record, the result the AddColumns formula returned would be updated, so the Gallery items would be refreshed/updated. In default, the first item of the Gallery control would be selected.

If you want to not change the selected item within the Gallery control when you patch a value for any ticket record, please take a try with the following workaround:

Set the OnSelect property of the Gallery control or the Navigate icon ( ">") button within the Gallery control to following formula:

Set(CurrentSelectItem,ThisItem)

Set the Default property of the Gallery control to following formula:

CurrentSelectItem

Set the TemplateFill property of the Gallery control to following (Set a background color for the selected item to distinguish😞

If(ThisItem.ID=CurrentSelectItem.ID,RGBA( 255, 105, 180, 1 ),RGBA(0, 0, 0, 0))

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps 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

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Users online (3,505)