Gallery1 holds some table data, but only shows the n column. Its purpose is to use wrapcount to show lots of items with basic information.
Gallery1.Items=
Table( {n: 1, data1: "C", data2: "d"}, {n: 2, data1: "A", data2: "o"}, {n: 3, data1: "T", data2: "g"} )
You need to click Button1, which is an item in Gallery1, to see more information in Gallery2.
Button1.OnSelect=
UpdateContext({ShowGallery2: true})
Gallery2.Visible=
ShowGallery2
Gallery2 holds the same data, but shows only one entry at a time in a "fullscreen" view. So you will see n, data1, and data2. Nothing is filtered--the template is just so big that the others are not shown.
If I tap Button1 for the second entry,
{n: 2, data1: "A", data2: "o"}
Gallery2 will appear, but it starts at the beginning of the table.
To get it to start at the nth entry, I did a little trick with Gallery2.
Gallery2.Items=
Sort(
AddColumns(Gallery1.AllItems,"Reorder",
If(n<Gallery1.Selected,n, Max(Gallery1.AllItems,n)-Abs(n-Gallery1.Selected.n)), (n-Gallery1.Selected.n),
Reorder)
I added a column that recalculated the n number, and then sorted the gallery based on that.
It works, but there are some limitations.
Gallery1.Items=
Sort(Table( {n: 1, data1: "C", data2: "d"}, {n: 2, data1: "A", data2: "o"}, {n: 3, data1: "T", data2: "g"} ),data1)
So here's my question: is there a way to get Gallery2 to start at the selected item and still maintain the order of Gallery1?
Solved! Go to Solution.
Gallery1 and Gallery2 should point to the same Items. This can be the same datasource, context variable etc. One way I achieved this is by setting OnVisible of Screen1 to be ClearCollect(Table,
{num: 1},
{num: 2},
{num: 3},
{num: 4},
{num: 5}
)
Gallery1.Items = Table
Gallery2.Items = Table
Once I did this, it worked for me.
Hello - Gallery has a "Default" property which helps you set the default selection. Normally "Default" is empty meaning the selection is on the first item. You could do the following to achieve the effect you want.
On the button you mentioned below where you set
UpdateContext({ShowGallery2: true})
do the following in addition
UpdateContext({ShowGallery2: true, Gallery1Selection: ThisItem})
Set Gallery2.Default =Gallery1Selection
Let us know if this helps.
Murali
Hi murali,
I had previously used the method you mentioned and tested it again. It seems that the Default property is not working in that case. Here is a quick mockup:
https://drive.google.com/open?id=0B0iHNZhZKR6YSHhPSWxDS1RLeTQ
Gallery1 and Gallery2 should point to the same Items. This can be the same datasource, context variable etc. One way I achieved this is by setting OnVisible of Screen1 to be ClearCollect(Table,
{num: 1},
{num: 2},
{num: 3},
{num: 4},
{num: 5}
)
Gallery1.Items = Table
Gallery2.Items = Table
Once I did this, it worked for me.
Confirmed. Problem solved.
Thank you.
I have created an idea for the Reset property of galleries. Please add your kudos to it, thanks.
https://powerusers.microsoft.com/t5/PowerApps-Ideas/Add-a-Reset-property-to-galleries/idi-p/18128
This solves the issue of resetting to the default item
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
User | Count |
---|---|
186 | |
95 | |
66 | |
64 | |
58 |
User | Count |
---|---|
243 | |
163 | |
94 | |
82 | |
80 |