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 / Remove a row from the ...
Power Apps
Unanswered

Remove a row from the view of a gallery ( Not remove from data source) when using a custom connector

(0) ShareShare
ReportReport
Posted on by

How do I remove a selected row from gallery, if I don't want to alter the data source itself ( since it is from a custom connector using a set of APIs to retrieve the data) ?

I

Categories:
I have the same question (0)
  • Verified answer
    RusselThomas Profile Picture
    4,014 on at

    Hi regenx,

     

    It helps if your Gallery is rendering a collection of your source, as opposed to being connected directly to the source.

    I believe Gallery's render data in a source but they are not sources themselves, so you can't edit the data in the gallery (that I know of), you have to edit the source it's referencing.

     

    To avoid editing your source data, you can create a limited copy of it in your app using something called a Collection.

    You would need to first collect the data from your source into a collection, then use the Gallery to render the collection.  You can then remove/add/edit items from the collection and this would be reflected in the Gallery, however without affecting the source.  

     

    Please be aware that Collecting data is limited to 500 rows at a time, (or 2000 with preview settings enabled) so you may want to filter your data to make it more relevant.  Even Galleries connected directly to source only render 500 rows at a time (they fetch 500 at a time as you scroll through the data), but with filtering sources you need to take delegation into account.   

     

    To collect data;

    Collect(myCollectionName, source)

    where myCollectionName is a name you give your collection and source is the name of the custom connector source you've added to your app.  There is no Filter applied to this formula, so it will simply return the first 500 rows of data.

     

    You can then create a Gallery and set it's Items property to myCollectionName 

     

    From here, you can decide how best to facilitate removing data from your collected copy rendered in the Gallery - if you want to do it one-by-one in the gallery, then edit the first card of the gallery and insert something like a trashcan icon.  It should appear on each row of the gallery if you're adding it to the right place.  You can then set its OnSelect property to

    Remove(myCollectionName, ThisItem)

    If you prefer to have one delete button somewhere on your screen, you can just add a button, change the button text to "Delete" and then set it's OnSelect property to

    Remove(myCollectionName, GalleryName.Selected)

    where GalleryName is the name of your Gallery.  This will delete the currently selected item in the gallery.

     

    Hope this helps,

     

    RT

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    All solutions like the one above that involve a collection will only work temporarily as the next time the app is opened, the changes will not be retained. If you want to retain the changes, you could add a Boolian field to the DataSource ie. "hide".  Then add a Toggle to the gallery that uses that field as it's item, ie.ThisItem.hide. Make the OnSelect property of the toggle Patch(DataSource, ID=ThisItem.ID,{hide: true})  In the Items property of the gallery, filter the DataSource on the new column, ie. Filter(DataSource,hide=false).  

  • Community Power Platform Member Profile Picture
    on at

    Is there a way to remove a duplicate row from the gallery and still display all the columns, not just one as in the case of Distinct() method.

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    You could put a button outside the gallery with onselect property Remove(data source,Lookup(data source,id =gallery.selected.id)).

  • Community Power Platform Member Profile Picture
    on at

    Instead of the current row selected, I want to remove all the rows that are extra (The result would be all unique records in the gallery). 

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Here are two ways to do that. 

    1) Use Distinct() and then add back the fields that you wish to display by wrapping the result in AddColumns().  For example make the Items property of the gallery:  AddColumns(Distinct(datasource,Field1), "FieldName2",Field2,"FieldName3",Field3,etc.).

     

     

    2) If you wanted to "clean up" your datasource by removing the duplicates, Export your datasource into Excel and use the Remove Duplicates feature. Then import the datasource back into Powerapps.

     

    The first method has the advantage that it does not change your datasource but it could slow down displaying the gallery. To speed up displaying the gallery, you could create a Collection by wrapping the above formula as ClearCollect(ds, AddColumns(Distinct(datasource,Field1), "FieldName2",Field2,"FieldName3",Field3,etc.)) and use ds as the Items property of the gallery.  

     

     

     

  • AlbertoSP Profile Picture
    118 on at

    Is there a rule to prevent a user from deleting the 1st row?
    My On select action on a (delete icon) is Remove(MyCollection,ThisItem).
    Works great but also allow users to delet the first row and then the form is blank.

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard