cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Nested gallery, trying to collect data from 1st sub gallery

Just started with powerapps and my first post in this community is a question, sorry, anyway this is a great tool  kudos to microsoft PowerApps team and community, this has a lot of potential like my darling PowerBI 🙂

 

I'm trying to build an asset ordering tool, I have created a collapsable subgallery inside main gallery. Main gallery which contains the contry+client code from PowerBI data integration and Subgallery from Catalog.xlsx

 

When I'm trying to Collect data from the 1st subgallery as show in the screenshot, the Order.Value and Units.Value(true and 3 respectively on the sample below) are not being fetched. The weird thing is it only happen on the 1st subgallery/row, when I expand the 2nd up to last and ClearCollect from there it's working fine.

 

I have seen a post about some issue with 1st subgallery not showing from this link:

https://powerusers.microsoft.com/t5/General-Discussion/Nested-Gallery-1st-Item-not-displaying-sub-ga...

but the solution there didn't worked on my case, on my it's showing I'm just not able to fetch the selected/input value

 

Please use below as reference, let me know if you need other info that can be of help.

 

Capture.PNG

 

Appreciate any help, thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Nested gallery, trying to collect data from 1st sub gallery

I experienced this issue as well. The workaround I came up with isn't too elegant, but it works.

 

To start, in the OnSelect property of the subgallery item I was clicking, I did an UpdateContext which grabs the ID of the current item. Specifically,

 

UpdateContext({SubGallerySelection: ThisItem.ID})

 

Then, I hid a gallery that has the same information as the subgallery and filter the ID by the SubGallerySelection variable. In the Items section of that gallery I have:

 

Filter(SubGalleryCollection, ID = SubGallerySelection)

 

After this, you should be able to pull any information you need from the subgallery item by referencing the hidden gallery. I did something like this:

 

HiddenGallery.Selected.Info

 

In my case, I am passing the information from the hidden gallery to a form to edit info in a database and it seems to work pretty well so far.

 

One important note: I am using a collection for the hidden gallery to make the sorting fast and the UpdateContext is the first action that is taken when clicking in my subgallery. Trying to go directly from my datasource made it so the hidden gallery wasn't sorted quickly enough for my needs.

 

If I need to elaborate on this, I am happy to. Hope this helps anyone else having issues with interacting with data in a subgallery!

View solution in original post

11 REPLIES 11
Mike8
Level 10

Re: Nested gallery, trying to collect data from 1st sub gallery

I also have a similar problem.. Please help.

bishoy
Level: Powered On

Re: Nested gallery, trying to collect data from 1st sub gallery

i have the same issue , would you please help 🙂 

 

Thanks in advance 

Anonymous
Not applicable

Re: Nested gallery, trying to collect data from 1st sub gallery

If this is a bug, hopefully someone has a workaround. Appreciate any help.

Super User
Super User

Re: Nested gallery, trying to collect data from 1st sub gallery

I experienced this issue as well. The workaround I came up with isn't too elegant, but it works.

 

To start, in the OnSelect property of the subgallery item I was clicking, I did an UpdateContext which grabs the ID of the current item. Specifically,

 

UpdateContext({SubGallerySelection: ThisItem.ID})

 

Then, I hid a gallery that has the same information as the subgallery and filter the ID by the SubGallerySelection variable. In the Items section of that gallery I have:

 

Filter(SubGalleryCollection, ID = SubGallerySelection)

 

After this, you should be able to pull any information you need from the subgallery item by referencing the hidden gallery. I did something like this:

 

HiddenGallery.Selected.Info

 

In my case, I am passing the information from the hidden gallery to a form to edit info in a database and it seems to work pretty well so far.

 

One important note: I am using a collection for the hidden gallery to make the sorting fast and the UpdateContext is the first action that is taken when clicking in my subgallery. Trying to go directly from my datasource made it so the hidden gallery wasn't sorted quickly enough for my needs.

 

If I need to elaborate on this, I am happy to. Hope this helps anyone else having issues with interacting with data in a subgallery!

View solution in original post

nickduxfield
Level 8

Re: Nested gallery, trying to collect data from 1st sub gallery

Together with previous Get ID. Do you Do collections, and Collections of Collection on each gallery walthrough?

If so the ClearCollect / Collect may need to be thought through.

Does this app having Offline write to device, is this why dou need Collections? 

Anonymous
Not applicable

Re: Nested gallery, trying to collect data from 1st sub gallery

Awesome, thanks for the input wyotim, although currently I won't be able to test it as I have changed the structure of my app.

 

Anyway I'll mark this as one of possible solution to this problem incase other user experienced the same

 

Thanks a lot

Anonymous
Not applicable

Re: Nested gallery, trying to collect data from 1st sub gallery

The button on each of the collapsable gallery will collect(not clearcollect as shown in the screenshot, I did that on purpose just to test the first gallery), and then the Request Quotation button will provide an offline summary then upon submit patch update it to a database. Unfortunately I have change it altogether on the current iteration it wound be a nested gallery. Thanks for the reply btw Smiley Happy

itsJoost
Level: Power Up

Re: Nested gallery, trying to collect data from 1st sub gallery

Hi @wyotim,

 

This expaination has helped me a lot! Now I do need the faster loading... As for now when I select an item it sometime takes two or thee click to load properly. Could you elaborate on the use of the collection for the hidden gallery in this matter?

 

Thanks in advance!

 

Cheers

Super User
Super User

Re: Nested gallery, trying to collect data from 1st sub gallery

Hi @itsJoost! I'd be happy to share as much as I can...and as much as I can remember. Smiley Very Happy It has been a while since I implemented this solution and I haven't done anything quite like it since (for reasons that I will explain later). I'll give you what I have and we can go from there though.

 

For some background, this solution is part of an employee data management app and, in particular, a section used to track training records for HSE compliance. An employee is selected from a gallery and in the OnSelect property of that gallery all relevant records are collected from our database in a Concurrent function, like so:

// Irrelevant code replaced by an ellipsis
...
Concurrent(
    ClearCollect(TempTrainingRecordsCollection, 
        Sort(
            Filter('[dbo].[TrainingRecords]', 
                EmployeeID = ThisItem.ID
            ), 
            TrainingDate, 
            Descending
        )
    ),
    ...
    ),
    ...
);
...

 

The TempTrainingRecordsCollection is tied to the hidden gallery, named TrainingSelectionHelper. The only real function of the TrainingSelectionHelper gallery is for help editing training history items. When an item from TrainingHistoryGallery is selected for editing, a variable is updated as such:

// OnSelect of the edit icon in the TrainingHistoryGallery
UpdateContext({SelectedTraining: ThisItem.ID})


In the Items property of TrainingSelectionHelper is the following:

LookUp(TempTrainingRecordsCollection, SelectedTraining = ID)

Then the form used to edit the selected item has the following in the Item property:

TrainingSelectionHelper.Selected

 

So essentially, the TrainingSelectionHelper is just a single item gallery that holds the record for the training item to be edited. Why I did it this way I can't really recall. At any rate, I would now just use a variable to hold the record and skip the hidden gallery, which is why I haven't done anything like this since. So instead of the code sections above, I would do this:

// OnSelect of the edit icon in the TrainingHistoryGallery
UpdateContext({SelectedTraining: ThisItem})

Then in the Item property of the form I would put:

SelectedTraining

instead of referencing the single item in the hidden gallery. (In fact, I did change this as the app still had the hidden gallery technique!)

Again, why I went this route is a mystery to me. It was probably an idea that worked and I have learned some better ways to accomplish it since then. I'm betting I didn't know storing a record in a variable was possible and improvised a way around it. Hopefully, that wordy mess explains a bit of the approach though.

 

As far as the issue with needing multiple clicks to load properly, what is it doing exactly? I'd be happy to try and troubleshoot things with you if you like.

Helpful resources

Announcements
thirdimage

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 210 members 5,288 guests
Please welcome our newest community members: