Nested Gallery Expand and Collapse in Power apps

Loading

Requirement: Create a Nested Gallery which will Expand and Collapse using icons in Powerapps.

Create a Blank Canvas app in that Insert a “Flexible Height” Gallery. Rename it as “Parentgallery” Add

data source to the gallery. Inside the Parentgallery insert “Blank Flexible Height” gallery. Rename it as “Subgallery” and add Data Source to the Subgallery. Add Up and Down icons to the Parentgallery.

First set the variable in OnSelect property of the downicon is :

Set(VarWorkID,ThisItem.ID).

In Visible property of the downicon write below mentioned condition :

If(varWorkID=Thisitem.ID,true,false).

Go to the OnSelect property of the downicon and add another logic :

If(VarWorkID=ThisItem.ID,Set(VarWorkID,0),Set(VarWorkID,ThisItem.ID)).

Again we need to go to the Visible property of the down Icon. Additionally, we are going to add another logic the this. If Statement is replaced with a Switch statement .

Switch(VarWorkID,0,true,ThisItem.ID,false,true).

Additionally, Set another variable in OnSelect property of downicon mentioned below :

If(VarWorkID=ThisItem.ID, true,Set(VarWorkID,0),Set(VarWorkID,ThisItem.ID));Set(Test,!Test).

Similar to downicon.

Change the properties of Upicon in the same way as downicon.

In OnSelect property of Upicon write below mentioned formula :

If(VarWorkID=ThisItem.ID, true,Set(VarWorkID,0),Set(VarWorkID,ThisItem.ID));Set(Test,!Test)

In Visible property of upicon write below mentioned Switch statement :

Switch(VarWorkID,0,true,ThisItem.ID,false,true).

Declare that variable in Visible property of Subgallery is Test.

In Height property of Subgallery write below mentioned formula :

If(ThisItem.IsSelected, CountRows(SubGallery.AllItems) *300 ,0).

We have a Nested Gallery with Categories and Sub-categories.

The categories will be shown first, If we want to see the Sub-categories that are present in the Subgallery,Click on downicon to Expand it.

If we want to see the categories present in the Parentgallery, Click on upicon to Collapse it.

To click the downicon to Expand it. The Sub-categories preset in the Subgallery are visible.

If the user want to see the categories that are present in the Parentgallery, Click on upicon to Collapse it.

Leave a Reply

Your email address will not be published. Required fields are marked *