cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Richard95
Helper I
Helper I

hide a record from a gallery by a boleean toogle

I have a SQL View that doesn't contain any columns regarding boolean values, what I would like to know if there is any way to do it is that by inserting a Toogle and depending on its false or true value, it hides that record from the gallery. but obviously being a view it would not modify any value in the Database, it would be only visual for the user

 

Richard95_0-1645029921080.png


Thanks for the attention.

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
bnerd
Helper II
Helper II

Just tested it successfully with a table titled tblRooms in my app.

Hope this animated gif can illustrate better what I did - 
Toggle button to remove items from the galleryToggle button to remove items from the gallery

 

But looking at this, toggle button doesn't really make sense much because the item disappears before you can see the toggle switched on. You might be better off with a button titled "Hide" or similar.

View solution in original post

That's great @Richard95, pleased you got it working.

 

Please click Accept as solution in the post that 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 Thumbs Up. 

View solution in original post

12 REPLIES 12
bnerd
Helper II
Helper II

Create a collection using data from SQL and a column for your toggle control. Set your gallery items to the collection. You can then filter collection based on the toggle value. 

 

Hope this helps.

Hello, could you explain me a little more I think I did not understand very well the collection with SQL data

bnerd
Helper II
Helper II

You need to create a new collection with your data plus an additional column for your toggle, something like:

ClearCollect(
    mySQLRecordsWithToggle,
    AddColumns(
        SQLTableName,
        "ToggleSwitch",
        false
    )
)

 mySQLRecordsWithToggle collection should now have all your SQL data plus one additional column for the toggle, set to false. 

 

You set your gallery items value to mySQLRecordsWithToggle.

 

When users change the toggle to Checked, you can run filter something like to get only those records for which hide toggle is not checked (false).

Filter(mySQLRecordsWithToggle, ToggleSwitch.Checked = false)

 

Hope this helps.

From what I see if or if I had to create a table and not work with a view to be able to do that


@Richard95 wrote:

From what I see if or if I had to create a table and not work with a view to be able to do that


You should be able to use the View just as you would the table.

I already created the column and set it to False for all values, now how do I make changes in that record when I activate toggle2?

 

Richard95_0-1645112087125.png

 

Hi @Richard95 

 

first of all create a collection using the sample I gave your above. Then set gallery Items to Filter only those items for which ToggleSwitch value is false.

Filter(<your collection name here>, ToggleSwitch = false)

You toggle control needs to have DisplayMode set to Edit so you can flick it as you browse your items. 

On the OnCheck for the Toggle control you add Patch function to update collection and set the value of the ToggleSwitch column to true, something like this:

Patch(
    <your collection name here>,
    ThisItem,
    {ToggleSwitch: true}
);

This will flick make the item hide from the gallery soon as you switch the toggle to true.

 

Hope this helps.

bnerd
Helper II
Helper II

Just tested it successfully with a table titled tblRooms in my app.

Hope this animated gif can illustrate better what I did - 
Toggle button to remove items from the galleryToggle button to remove items from the gallery

 

But looking at this, toggle button doesn't really make sense much because the item disappears before you can see the toggle switched on. You might be better off with a button titled "Hide" or similar.

Hello, thank you very much, I am beginning to understand a little more, but I still do not understand very well this part of creating the Collection

Richard95_0-1645121967656.png

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,949)