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 / Issue with Gallery Ins...
Power Apps
Suggested Answer

Issue with Gallery Inside a Component

(1) ShareShare
ReportReport
Posted on by 6
I have a component that contains a simple Gallery that is fed items from the component's Items custom property which accepts a table. If there are items when the component renders the first time, items show as expected, but from that point forward if the items change then the gallery will not refresh or render any items -- it will just be a blank gallery. To troubleshoot, I added a table to show the component's items, and that refreshes with the correct data every time. I also added a Text control to show the number of items that are in the Gallery (AllItemsCount property), and it correctly shows the number of items even though the gallery is blank. There are no special formulas on the controls in the gallery that would affect sizes and visibilities. It's a simple, simple gallery. 
 
Has anyone seen similar issues? I hadn't come across this problem until today. 
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,073 Most Valuable Professional on at
    It is really not good practice to have controls in components accessing data sources - components are designed to be "self-contained" elements. What you are experiencing is not unexpected. You might consider putting the gallery in the app itself.
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn   
  • RC-15052008-0 Profile Picture
    6 on at
    Hmm, just making sure we are speaking the same language... what I have is a no-code component that I am building using Power Apps Design Studio. Are you saying it's bad to put Gallery controls (or any control) in a no-code component? What else would you put in a no-code component? My component does not access app scope, so it instead has an input property that contains the data to display in the Gallery, so that the Gallery is not directly accessing a data source. Does that help clarify the scenario? Thanks for the reply btw! 
  • WarrenBelz Profile Picture
    153,073 Most Valuable Professional on at
    My understanding (I do not use them a lot) is that you can certainly have "self contained" code such as a menu, but they are not able to query data "external" to the Component. Here is a thread from the Power Apps Ideas Forum requesting this function. I normally prefer using my own words in responses, but this Google response to the question I think sets it out well.

    The main issue with accessing a data source from a Power Apps component is that components are not designed to directly handle data source connections or operations. Components primarily work with data passed in as properties and use those properties to interact with the wider app's data context. 
     
    Here's a more detailed breakdown of the challenges: 
     
    • Limited Data Access:
      Components can't directly connect to a data source like SharePoint or SQL. They primarily work with data that is passed to them as properties.
    • No Direct Data Source Management:
      Components don't have their own data source connections or the ability to create or manage them.
    • No Local or Global Variables:
      Components cannot use local or global variables to store data. They rely on properties passed from the parent app.
    • UpdateContext is Not Supported:
      The UpdateContext function, used for modifying data, is not supported within a component.
    • No Direct Data Modification:
      Components cannot directly modify a data source. They must rely on functions in the parent app to handle data updates.
    • No Media Files:
      You cannot package media files when importing a component, says a YouTube video.
    Workarounds:
    To work around these limitations, you can use the following strategies:
    • Use Properties:
      Pass the data source name, table name, and other relevant information as properties to the component. 
       
    • Implement Logic in the Parent App:
      Handle data source operations (like fetching, updating, or deleting data) in the parent app and pass the results to the component. 
       
    • Use the UpdateContext Function:
      Use the UpdateContext function in the parent app to modify the data source, and then pass the updated data to the component via properties. 
       
    • Consider Collections:
      If you need temporary data storage within the component, you can use collections. However, collections are limited and will not persist across app sessions. 
       
    In summary, while Power Apps components are powerful for creating reusable UI elements, they are not designed to directly handle data source connections or operations. You must use the component as a UI element and pass data and logic from the parent app, says a YouTube video. 
  • Suggested answer
    RC-15052008-0 Profile Picture
    6 on at
    OK, then yes, I have designed my component exactly the way you describe, by using properties and not direct data connections. 
     
    I was able to successfully create an example in a new app and it seemed to work just fine. So there's likely some other issue, e.g. multiple components on the screen that is throwing a wrench into things. So, I then just broke up the screen into multiple simpler screens to work around this. Not ideal for where I am at, but I can live with it; likely going to have to do that at some point anyway. 
     
    I truly do appreciate your replies. Thank you.

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard