cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

How to avoid that first item is selected after navigating back using Sort functionality

Hi,

 

I have added Sort in the formula of my items property of the gallery.

But now when I edit a record and navigate back to my gallery, the first item is selected automatically.

When I remove the Sort from the formula, the edited record is still shown after I navigate back (desired behavior).

Is there a setting I can use for this?

Thx

Kr

 

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: How to avoid that first item is selected after navigating back using Sort functionality

Hi @ThomasVDS ,

Since you have navigate to gallery screen, how do you find the edit form display the first record?

I'm a little confused about your issue.

Could you show me your screenshoots?

 

What's more, you could try to use 'Modified' field to make sure the edit form display the item that you editted just now.

Try this formula:  (set the edit form's Item)

If(Gallery1.Selected=First(Sort(gallery,......,...)),            
First(SortByColumns(tablename,"Modified",Descending)), //display the item that you editted just now
Gallery1.Selected) //display the selected item

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper III
Helper III

Re: How to avoid that first item is selected after navigating back using Sort functionality

@v-yutliu-msftI'll give more explanation.

I have a screen with gallery and form view mode (see print screen).

The 'Items' property of the gallery is: 

SortByColumns(Search('[dbo].[Consultants]',txtSearchConsultant.Text,"ConsultantID","FirstName","LastName"),"ConsultantID",Ascending)

The part in red I have added at a later stage. This is causing the issue I have now.

The 'Item' property of the form view: galConsultants.Selected

When I edit a value of the form in a separate screen (see print screen) and click to submit and navigate back to the first screen. Then the first item of the gallery is now selected and not the one I modified. When I click on the cancel button in the edit screen (ResetForm and Back()), it works fine.

It looks like that the submit function is telling to reselect the gallery.

 

Consultant_sort issue_before.PNGEdit consultant.PNGConsultant_sort issue_after.PNG

 

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (12,427)