cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
regenx
Level: Powered On

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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

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

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

View solution in original post

7 REPLIES 7
Super User
Super User

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

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

View solution in original post

Super User
Super User

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

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).  

regenx
Level: Powered On

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

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.

Super User
Super User

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

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

regenx
Level: Powered On

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

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). 

Super User
Super User

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

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
Level: Powered On

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

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.

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 (Last 30 Days)
Users online (5,693)