Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Set Gallery Default Selected Item beyond the first 100 items

Posted on by 23

I have a Gallery populating from a delegable call to a Dataverse Table with over 100 items, so the Gallery will only load 100 items at a time as the user scrolls.

 

If I attempt to set the Default Selected Item to any of the first 100 items, it is selected as expected in the Gallery. But when I attempt to set the default item to anything beyond the 100th item, the Gallery can't select it b/c its not in view of the first 100 items. I've tried setting default selected manually to a Record like {ID:101}, w/ a variable or collection set somewhere else in the app like varSelectRecordID101 or colSelectRecordID101, w/ lookup to self: LookUp(Self.AllItems, ID = 101), or from form submissions like Form1.LastSubmit and all can only select a default item if its loaded in view within the Gallery.

 

If the Gallery is already scrolled down by the user to the point where the intended Default Selected Item is visible it gets selected, but I do not see an option to indicate the Gallery should automatically expand without user input and load the next 100 items at a time until it finds and can select the Default Selected item. This seems possible as Last(Self.AllItems) does exactly that to expand until it hits the very last record, then selects it (*Note* Last(<Datasource>) does not do this automatic expansion, only Self.AllItems).

 

Anyone know how to get around this without breaking the Delegable call to Dataverse or introducing Row Item Limits inside the app to load all of the data into the Gallery instead of 100 rows at a time?

 

Thanks in advance!

 

Edit: Updated Last(<Datasource>) to Last(Self.AllItems). Last(<Datasource>)  does NOT expand all items but Last(Self.AllItems) does.

  • trstrean Profile Picture
    trstrean 175 on at
    Re: Set Gallery Default Selected Item beyond the first 100 items

    @WarrenBelz I agree.  Since galleries don't automatically scroll to a default, I'm not sure anything would really accomplish this task. In theory, you could set a default, and when you finally scroll to it, it would be highlighted as the default selected item...something like: Set(varSelectedItem, LookUp(DataSource, ID = 500)) and then set the default setting to the variable.  I'd have to ask why setting the default to a particular record is necessary?  If the newest records are the goal, filtering/sort by createdon is more effective to allow the user to scroll from newest to oldest.  Or adding some range filters, maybe.  I haven't tested it, but the new table control might (still not auto scroll  capable) retain selection past 100 items.

  • cwebb365 Profile Picture
    cwebb365 3,309 on at
    Re: Set Gallery Default Selected Item beyond the first 100 items

    You would think but something is causing it to render out and it being non delegable makes the most sense for the reason. Would need more testing to know for sure. Fun project I guess 😂 

  • WarrenBelz Profile Picture
    WarrenBelz 142,733 on at
    Re: Set Gallery Default Selected Item beyond the first 100 items

    @trstrean ,

    If you go back to my post, the theory is probably correct. Although Items and Default need to be compatible, they are separate functions. Default simply describes a Record that the Gallery needs to display and select by default. If it is not present, it simply does not select it. Having a non-Delegable query in Default does not then turn the Items into a non-Delegable query.

  • kyasprin Profile Picture
    kyasprin 23 on at
    Re: Set Gallery Default Selected Item beyond the first 100 items

    These datasources will likely grow beyond a couple thousand records. I was initially thinking of using the Default property to autoselect a newly added record from a form on the same screen as selecting the new record then has some other related functionality on the screen that would be nice to display automatically to the user after adding the new record. In addition to having this record auto selected display related content in other areas of the screen the user could see the item they just added selected and be able to scroll up and down in the Gallery from there to view/edit other items. But these aren't great options for resource utilization, especially as more and more of the Gallery would need loaded to autoselect.

     

    I do have some text search and combo box filters that I had some initial hesitations on populating with the newly added record from the form with a variable, but I think this is the right way to go to retain delegable data calls in the Gallery while also selecting and displaying the newly added record to showcase the related content displayed on the page.

     

    Thanks all!

  • Verified answer
    trstrean Profile Picture
    trstrean 175 on at
    Re: Set Gallery Default Selected Item beyond the first 100 items

    It seems like an easier approach is to give the user the ability to apply filters and reduce how much scrolling is necessary.  You could add a text search or some combo boxes that allow the user to filter things down and then the gallery would likely contain less than 100 items and avoid the issue 99% of the time.   Is there a reason why the user must scroll through more than 100 items where a filter wouldn't be desirable?

  • cwebb365 Profile Picture
    cwebb365 3,309 on at
    Re: Set Gallery Default Selected Item beyond the first 100 items

    Last is non delegable so it’s having to return all records to get to it.  How large is this gallery supposed to get to? Seems like a UX issue to be scrolling so much to items? 

    how many items can be in this gallery over time? If you just have to have a full gallery and it’ll always be under 2000 records then force a non delegable or use with / make a collection on load for it from your data source to pull the records local then use that as your items for the gallery. You can simple patch the collection right back to the data source with minimal effort patch(data source,collection) for updates.  

  • kyasprin Profile Picture
    kyasprin 23 on at
    Re: Set Gallery Default Selected Item beyond the first 100 items

    You are correct Last(<Datasource>) does not expand, but Last(Self.AllItems) does. Its interesting that Self.AllItems knows to continue pulling records automatically to expand and select the Default Item even if its beyond what is currently visible, but Last(<datasource>), Index(<Datasource or Self.AllItems>, ID = <SomethingAbove100>), or a Variable setting a record higher than displayed 100 items doesn't trigger the same expansion to pull more records until the selected item is visible.

     

    I updated my original post to indicate Last(<Self.AllItems) does work but Last(<Datasource>) does not.

     

    I'll have to keep pondering how I might be able to step around this and will post here if I can come up with something useful.

  • kyasprin Profile Picture
    kyasprin 23 on at
    Re: Set Gallery Default Selected Item beyond the first 100 items

    LookUp(<DataverseTable>, ID = <SomethingPast101>) and LookUp(Self.AllItems, ID = <SomethingPast101>) Both are limited to selecting from only the visible items in the Gallery. So initially only 100 items display for delegable calls to the Dataverse Table, so only the first 100 items can be set as the default. If user scrolls down to the bottom of the Gallery and the next 100 items loads, the Default from there can then be set to the first 200 items that are now displaying.

  • WarrenBelz Profile Picture
    WarrenBelz 142,733 on at
    Re: Set Gallery Default Selected Item beyond the first 100 items

    @kyasprin ,

    I just did some testing here and (as expected) cannot get the Default to present past 100 items (without scrolling) using Last (simply does not work) Index (works up to 100, then does not) or LookUp (same as Index).

  • cwebb365 Profile Picture
    cwebb365 3,309 on at
    Re: Set Gallery Default Selected Item beyond the first 100 items

    So have you tried Lookup(SameasItemsDatasource,id= andIDPast100) as default selected? 

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

October 2024 Newsletter…

October 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #4 How to Conntact Support…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 142,733

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,750

Leaderboard