Reply
Highlighted
Level: Powered On
Posts: 18
Registered: ‎09-07-2016
Accepted Solution

Remove Item from Browse Gallery

Is it possible to remove an item from a browse galelry by clicking on a button within a record of the gallery?

 

I'm looking for somthing like Remove(<<RECORD>>, ThisItem)

 

But I don't know what to pass as first argument. Thanks a lot!


Accepted Solutions
Level 8
Posts: 140
Registered: ‎07-25-2016

Re: Remove Item from Browse Gallery

Syntax for remove is Remove(DataSource, Record).

 

You need to pass the datasource name as the first argument.

 

Check the below URL for the detailed description with examples.

https://powerapps.microsoft.com/en-us/tutorials/function-remove-removeif/

 

 

View solution in original post

PowerApps Staff
Posts: 185
Registered: ‎08-25-2016

Re: Remove Item from Browse Gallery

 

You need to force the re-evaluation of your formula. Not the prettiest soution, but one way to do that is using a context variable:

 

    gallery.Items = If(true || counter, SortByColumns(MySource.SampleGetData(), "FileName", If(SortDescending1, Descending, Ascending)))

 

    removeButton.OnSelect = MySource.RemoveRow(.....); UpdateContext({counter: counter + 1})

 

Please let me know if this doesn't work for you.

 

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post


All Replies
Level 8
Posts: 140
Registered: ‎07-25-2016

Re: Remove Item from Browse Gallery

Syntax for remove is Remove(DataSource, Record).

 

You need to pass the datasource name as the first argument.

 

Check the below URL for the detailed description with examples.

https://powerapps.microsoft.com/en-us/tutorials/function-remove-removeif/

 

 

Level: Powered On
Posts: 18
Registered: ‎09-07-2016

Re: Remove Item from Browse Gallery

This is my datasource (custom restful service) for the control:

 

SortByColumns(MySource.SampleGetData(), "FileName", If(SortDescending1, SortOrder.Descending, SortOrder.Ascending))

What is than DataSource in the Remove method?

Level 8
Posts: 140
Registered: ‎07-25-2016

Re: Remove Item from Browse Gallery

If you are consuming the data through Custom REST API, then I afraid you can't use the Remove() function, since PowerApps does not know how to manipulate your data for the Remove operation. For the connections that you have added through PowerApps, it has the knowledge of CRUD operations for the source. In this case, you need to have a REST API for the Remove operation and call it from PowerApps.

 

 

Level: Powered On
Posts: 18
Registered: ‎09-07-2016

Re: Remove Item from Browse Gallery

Ok, I have such a method. How can I just refresh the control after clicking the button. I've tried to use the Refresh method, but can't get it to work.

Level: Powered On
Posts: 18
Registered: ‎09-07-2016

Re: Remove Item from Browse Gallery

Any news here?

PowerApps Staff
Posts: 185
Registered: ‎08-25-2016

Re: Remove Item from Browse Gallery

 

You need to force the re-evaluation of your formula. Not the prettiest soution, but one way to do that is using a context variable:

 

    gallery.Items = If(true || counter, SortByColumns(MySource.SampleGetData(), "FileName", If(SortDescending1, Descending, Ascending)))

 

    removeButton.OnSelect = MySource.RemoveRow(.....); UpdateContext({counter: counter + 1})

 

Please let me know if this doesn't work for you.

 

Radu Gruian [MSFT] ** PowerApps Staff
Level: Powered On
Posts: 18
Registered: ‎09-07-2016

Re: Remove Item from Browse Gallery

Yes, this is working. Thanks a lot. Is there some thing planned to make things like this easier? Maybe later some advanced JS support?

PowerApps Staff
Posts: 185
Registered: ‎08-25-2016

Re: Remove Item from Browse Gallery

We are indeed considering new ways to make operations like this easier. I am glad this solved your problem.

Radu Gruian [MSFT] ** PowerApps Staff
Level: Powered On
Posts: 17
Registered: ‎10-06-2017

Re: Remove Item from Browse Gallery

[ Edited ]

Hi Radu,

 

Thanks for clarifying this.

 

I've seen a few different approaches to solving this which kind of feel like "the long way around".  Do you know if anything has changed with regards to removing items from a collection since you last posted on this thread.

 

I've been working on removing an item from a local Collection and am facing a similar issue.

 

Many thanks!

Sean