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

GroupBy in a Gallery causes problems when a user selects an item

Hello,

I am working on a app, that is based on a SharePoint list.

I ordered the gallery in the browse screen with the following command:

SortByColumns(Filter(SupportTickets, StartsWith(SP_StatusText, "01") || StartsWith(SP_StatusText, "03")), "SP_StatusText" , If(SortDescending1, Descending, Ascending))

2019-02-09 15_33_15-Window.png

 

The detail section is configured as follows:

2019-02-09 15_43_51-Window.png

 

The problem is, that the item selection in the edit screen is not compatible with the datasource on my brows screen:

2019-02-09 15_37_33-Window.png

What do I have to change in order to make my app work?

Thanks a lot for your support.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: GroupBy in a Gallery causes problems when a user selects an item

Because of the way that you are using a ListBox in your Gallery to show the Grouped Items, you would have to set your EditForm1 item to something along these lines:

   LookUp(BrowseGallery.Selected.GroupByStatus, Title=ListBox1.Selected.Title)

 

This is because your listbox only will have a set of Title values in it.  

While the above will work - you could have incorrect results when working with the title only (as there could be duplicate titles and you would only get the first). 

The best to work with would be the ID, but the ListBox does not hold that information.

 

You might want to consider using another nested Gallery or another type of control like a ComboBox or DropDown.  All of those will allow you to assign a full collection (in this case your "GroupByStatus" table) to them.

 

The only obstacle I have found was getting the sub-gallery or sub-controls to be seen outside of the primary gallery. I typically just set a variable in the OnSelect

 

So, I would suggest something like this to try and see if it helps:

 

Get rid of the ListBox.

Add a Sub-Gallery to the Gallery (insert gallery into template) - Lets call it SubGallery

Set the Items of SubGallery to ThisItem.GroupByStatus

Add a Label to the SubGallery template and set its text to ThisItem.Title

To give a nice "select look" - go into the TemplateFill property of the SubGallery and set it to:

     If(ThisItem.IsSelected, RoyalBlue, White)

Go to the OnSelect action of your SubGallery and set it to:

     Set(selectedGroupItem, ThisItem)

 

NOW...go to your EditForm1 and set the Item to selectedGroupItem

 

So, this addresses your immediate question.  However, I can expect you will have some usability aspects to deal with.  The reason I say that is because I don't know from your question how it is that people get to the EditScreen1.  

If you are having them select an item and then click a button - this could lead to bad results as they could click on items in other groups.

 

If this becomes the case, then I would suggest changing your OnSelect to the following:

   Set(selectedGroupItem, ThisItem);  Navigate(EditScreen1, None)

 

 

I hope this helps out or at least points you in the correct direction.

 

5 REPLIES 5
Super User
Super User

Re: GroupBy in a Gallery causes problems when a user selects an item

Because of the way that you are using a ListBox in your Gallery to show the Grouped Items, you would have to set your EditForm1 item to something along these lines:

   LookUp(BrowseGallery.Selected.GroupByStatus, Title=ListBox1.Selected.Title)

 

This is because your listbox only will have a set of Title values in it.  

While the above will work - you could have incorrect results when working with the title only (as there could be duplicate titles and you would only get the first). 

The best to work with would be the ID, but the ListBox does not hold that information.

 

You might want to consider using another nested Gallery or another type of control like a ComboBox or DropDown.  All of those will allow you to assign a full collection (in this case your "GroupByStatus" table) to them.

 

The only obstacle I have found was getting the sub-gallery or sub-controls to be seen outside of the primary gallery. I typically just set a variable in the OnSelect

 

So, I would suggest something like this to try and see if it helps:

 

Get rid of the ListBox.

Add a Sub-Gallery to the Gallery (insert gallery into template) - Lets call it SubGallery

Set the Items of SubGallery to ThisItem.GroupByStatus

Add a Label to the SubGallery template and set its text to ThisItem.Title

To give a nice "select look" - go into the TemplateFill property of the SubGallery and set it to:

     If(ThisItem.IsSelected, RoyalBlue, White)

Go to the OnSelect action of your SubGallery and set it to:

     Set(selectedGroupItem, ThisItem)

 

NOW...go to your EditForm1 and set the Item to selectedGroupItem

 

So, this addresses your immediate question.  However, I can expect you will have some usability aspects to deal with.  The reason I say that is because I don't know from your question how it is that people get to the EditScreen1.  

If you are having them select an item and then click a button - this could lead to bad results as they could click on items in other groups.

 

If this becomes the case, then I would suggest changing your OnSelect to the following:

   Set(selectedGroupItem, ThisItem);  Navigate(EditScreen1, None)

 

 

I hope this helps out or at least points you in the correct direction.

 

sakleboe
Level: Powered On

Re: GroupBy in a Gallery causes problems when a user selects an item

Hi Randy,

You made my day!

Today I implemented  your solution proposal and so far it seems, that every thing works as expected.

BR,

Sascha

Super User
Super User

Re: GroupBy in a Gallery causes problems when a user selects an item

Excellent!! Always glad to hear things are working.

sakleboe
Level: Powered On

Re: GroupBy in a Gallery causes problems when a user selects an item

Hm...

Mabye I was a litle bit quick.

The behavior is as excpected, but the sub gallery only shows one item.

Could it be, that the label is not repeatable? 2019-02-13 21_13_31-Window.png

Super User
Super User

Re: GroupBy in a Gallery causes problems when a user selects an item

Have another look at your sub gallery.  It appears that there is a vertical scroll bar there.

Perhaps you just are not seeing it because of the height of the gallery?

 

Unfortunately, a standard gallery will not size itself properly as a sub gallery.  You will need to look into using a Flexible Height gallery.  And, another unfortunate, you can't just flip a property to make an existing one flexible.  You have to remove and insert the other.  Probably not a big deal at the stage you are in.

Also, even though it is flexible height gallery, you still have to do some tricks with it as a sub gallery to get it to size right.  If you get stumped with that, let me know.