web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Nested gallery will no...
Power Apps
Unanswered

Nested gallery will not collapse when not selected (not visible)

(0) ShareShare
ReportReport
Posted on by 235

I feel like I'd solved this already.  I had an app, there was something fundamentally wrong with it as no patches of columns from the gallery would work.  I could patch a literal value, but was unable to patch any of the gallery fields which absolutely had data in them.

When I'd click a button on the page with the gallery to do the patch, if I examined any of the fields I was attempting to patch they were null within that gallery and I know this because I put them in a variable and they were null.  So again, it would patch a literal value like "Hello there" to say a single line text field but it would not patch txtInputNotes  which was the field name in the gallery.  Nor txtInputNotes.Text  nor txtInputNotes.Value.   I tried every way possible but it wouldn't text anything but a literal in quotes.

 

I cut it down so bare that I finally gave up and thought I'd have to build a new gallery.  duplicated the page, built new gallery from scratch (well it's a groupby situation so I built 2).   I don't know if I can patch yet, just trying to finish the gallery to the point I had it before.  Now this new gallery is not hiding the nested gallery items when the parent is not selected.  I'm trying EVERYTHING.  I checked a video to recall if I did something wrong and in the video the child gallery was hidden simply by putting an IsSelected in the Visible property.     Sadly this isn't working for me either.   I don't want to pound on this for days and days if there's something fundamentally wrong with this new set of galleries I'm creating.  And since I never give up, I will waste days and days until I finally just give up and try again.

 

ANY suggestions are welcome I'm at wits end and working on my vacation time.   very sad.

Categories:
I have the same question (0)
  • sohilbhalla Profile Picture
    72 on at

    Hello, can you share the formula that you have put for the visible property of the child gallery?

  • AmyF Profile Picture
    235 on at

    It's just IsSelected on the visible property of the child.  I've solved that in one of the versions of my app, but the last thing seems to be the patch.  I know there's some "trick" to getting the child data values into some array or table that will persist when I click the button for the patch, because if I display them with a notify, they all have null values at that point but I can clearly see in the grid there are values.   I know it's the groupby now but I seem powerless to ungroup that so that I can get to the data.

    I tried that but the problem is I don't know where to Ungroup.  In the examples I've seen they mostly show only the Ungroup statement prior to the patch.  But when I do that I get an error that it doesn't recognize "Data" which is the name I put the grouped data into.    

    So my GroupBy is in the items property of the parent gallery, (with an AddColumn and Filter and Sort.   Everything displays and behaves well.   

    When I change a value, it's OnChange has Collect(getAllKids,{cID: ThisItem.ID});   and in the button OnSelect to perform the patch which uses a ForAll loop on that ID and that works.  but when I added another collection to the OnChange  Collect(getKidsData,{cStatus: ThisItem.Status});  and I displayed that with a Notify on the button before the patch, cStatus was null.

     

    So clearly this is not the way to go.

     

    Here's what I want it to do:

    OnChange of the fields in the grid, Collect the ID and separately the ID, Status, Status.Value, anyothercolumn, anyothercolumn.Value ...)

     

    So then I use the first collection of just IDs of rows with at least one change, do a LookUp on the datasource based on those IDs (and that works)  

    Then use the list of distinct IDs as a ForAll(  

    and then an inner ForAll that match the ID on the outer ForAll

    Either sort in Descending date/time order (I plan to put a timestamp on all changes while collecting) and process only the last patch for that ID  because it will hold the most recent version of what's to be patched.

     

    So the data rows that I collect for the changes would look like   

    ID, Field1, Field1Value, Field2, Field2value, etc...   

    and here I'll give you what the actual rows would look like:

     

    Assuming an ID of 1, and a Status, CourseName, Notes each one blank or having an old value and blank timestamp

    1, <blank>, <blank>, <blank>, <blank>

    1. Approved, <blank>, <blank>, 9/21/2023 13:25:33

    1, Approved, "History 101", <blank>, 9/21/2023 12:25:35

    1, Approved, "History 101", "These are my notes blah blah", 9/21/2023 12:25:39

     

    So, in this scenario where all 3 fields are being updated (plus a timestamp)  only the last one will be patched with the most recent timestamp.

     

    and then return to the refreshed grouped gallery

     

    The ID part is working as I was able to find the proper syntax on the internet.  But sadly, none of the fields have data because I haven't ungrouped.  AND I'm not sure where in my app to ungroup because when I tried that I got the following error:

    On the statement  Ungroup(myCollection, "Data");   The error is "The specified column 'Data' does not exist. but that is the name of the table of the non-grouped data.

     

    and, one more thing, every example I see from the experts show this scenario with the original GroupBy done on a button, mine is in the Items property.  So the scope of this is unclear and obviously wrong since the Data is always null because, I think, I haven't ungrouped the data.

     

    Sorry for such a wordy explanation but truly, I've been working on this for weeks and am still struggling.  

     

    Thanks in advance.

  • AmyF Profile Picture
    235 on at

    Sorry if I left that out it's 

     

    Collect(getAllKids,{cID: ThisItem.ID});    - this one collects just the ID and it works.  I added the following:

    Collect(getKidsData,{cStatus: ThisItem.Status})  didn't work. I tried with ThisItem.Status.Value also didn't work   but if I substitute ID for Status it works.   If I can expand the first collection to include the other fields (not sure of the syntax) that would work for me. 

    I tried the first collection to be: ,ClearCollect({cID: ThisItem.ID,

                                                         cStatus:  ThisItem.Status

                                                        }) 

    Just to add one field. didn't work,  also tried ThisItem.Status.Value   that didn't work.

     

    Oh, it made the collection (not the above code but the original one for status Collect(getKidsData,{cStatus: ThisItem.Status})  but it was full of nulls.  What's interesting is if I display the first collection of IDs in a gallery on the page and as I click I can see the IDs being collected, but when I displayed the second one with just the status everything was null.  so I can watch the first collection being populated but the second remains blank.

     

    I can capture the ID of the record of the nested gallery from a groupby, but I cannot capture the other data in that table for use in the patch.  So there's something about groupby that puts the data table into some other scope or something.  Remember your inner gallery items is simply   ThisItem.Data (or whatever you named it, once it's in the gallery you can refer to those fields but no where else.

     

    So I've read you need to Ungroup that data, I KNOW I have to do that.  I can't seem to make that happen syntactically without errors.       

     

     

     

  • Chris-D Profile Picture
    1,246 on at

    Hi Amy, never give up 💪😀

     

    It's a little difficult to understand what's going on here just by reading, could you put up a screenshot please and a simple description of what's supposed to happen? 

  • AmyF Profile Picture
    235 on at

    I hear ya, MaximumVerbosity = Off.   How's that?

    Attached is a picture instead of 1000 words.  But I will add that the problem is getting the data in the nested gallery "into" the button logic.  I can get the ID over there with the  OnChange on the field in the nested gallery by this line   Collect(getAllKids,{cID: ThisItem.ID})    BUT no other field gets over there, they are null.    AND I think that is correct, expected behavior of a GroupBy child gallery.    But I also think there's a way to Ungroup the data in order to write it or get at it, but I cannot get that to work in my scenario.

     

    Thanks.

  • Chris-D Profile Picture
    1,246 on at

    You have to do this 😉

    Set( MaximumVerbosity, false);

     

    Anyway... a picture is painting about 850 words, it's close! 

     

    Just check I understand it, your outer gallery is a grouped list of courses by month. You click on a month and the inner gallery shows a list of courses for that month. Approve/Reject/Waitlist will set the status for all the listed courses? Or is that a dropdown for each course? Approve & Save should save the status and notes for each. Did I get that right? 

     

    Can I see the code for inner gallery Items please? 

    You say 'no other field gets over there, they are null'. Which fields are going where? This code collects only the ID field which you say is getting 'there'. So that would be right?

    Collect(getAllKids,{cID: ThisItem.ID});

     

    This effectively makes a list of any record which has changed which you cycle through afterwards but otherwise I can't see any other fields being set anywhere. 

     

    In your Patch() code, you reference a combo box and a text input, are these the controls inside your child gallery? 

  • AmyF Profile Picture
    235 on at

    Yup.  GroupBy month  in this case, yes.

    Inner gallery normally would be ThisItem.Data  (where Data is the name of the table on the GroupBy statement).

    and yes to both of your last questions.   

     

    Note I found a place for the Ungroup and the syntax seems to be correct, now.  But, alas, it's still sending null values from the controls in the child gallery (the ones referenced in the patch)   I put in a Notify and verified that.  So, it seems that everything is mechanically working except the references to the child gallery items.  (and yes the Approved/Rejected/Waitlist is a combobox drop down  writing to a choice column on the sharepoint list.

  • Chris-D Profile Picture
    1,246 on at

    I thought that might be where the issue turned out to be. 

     

    You are trying to access the data field using the input control for the status/notes. But you only have one reference to the control. If the gallery has 5 rows, there are 5 copies of this control so you cannot access the values in this way. 

     

    To pull the values from a gallery you need to reference the control inside the gallery. Here's how. 

     

     

    // Lookup function to select the item we like.
    // I've done this based on ID column since you already have that in your code.
    LookUp( 
     // Use ForAll to make a lookup table of the fields from the gallery linked to their ID
     ForAll(
     Gallery1.AllItems As GalleryItem, {
     // Although gallery items have an ID field, this is NOT the ID of the record
     // ID of the record is stored as text in ItemID.Text
     ID: Value(GalleryItem.ItemID.Text),
    
     // InputNotes here is the name of the input control inside the gallery
     Text: GalleryItem.InputNotes.Text
     }
     ),
    
     // Now we can look up the ID field
     // Here I'm getting this from my example InputID text input control
     ID = Value(InputID.Text)
    
    // and .Text refers to the data we saved in the ForAll() step
    ).Text

     

     

    ChrisD_0-1694010171162.png

     

     

    I couldn't get a LookUp working directly on the Gallery.AllItems property, I think because you need to look up a nested piece of data but I might have another crack some time. 

     

    You might be able to do something easier here though. Since you are already pulling out the IDs, you could add to this like:

     

    // UNTESTED!
    Collect(getAllKids, {
     cID: ThisItem.ID,
     notes: ThisItem.TextInput.Text
    });

     

     

    That way you'd have the notes there in your Patch() without having to look each one up. That does present another problem though, since you're getting multiple entries in your getAllKids collection and then using Distinct() to resolve that, you'd have to do a Last( Filter( ...)) look up for each. 

     

    Either way should work though.

     

     

  • AmyF Profile Picture
    235 on at

    The last bit of code there (untested) didn't work.  Well, it collects the ID and both other fields are also collected but their values are both null.   For me, anyway.

     

    I notice in the prior solution you  reference the Gallery.  I don't do this.  Whenever I put in the names of my gallery I get an error.  

     

    I can only refer to the gallery controls by their name, if I preface it with Gallery10_6.  I get an error

     

    I know this can't be done without an Ungroup but I guess I'm still not implementing that correctly.

     

  • Chris-D Profile Picture
    1,246 on at

    You don't need an UnGroup() to reference controls in the gallery. 

     

    If you notice, I don't prefix the control name with the gallery name. My gallery is Gallery1, Gallery1 has InputNotes text input control. I'm not getting the value with Gallery1.InputNotes.Text, this won't work. I'm using ForAll() to make a list of ALL the gallery controls and their ID's, and the doing a LookUp() on this list. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard