cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Toggle Listbox select all

How would one go about connecting the Toggle to a Listbox?  My objective is let it select all items when on and unselect all when off.  This would allow users to faster select all/ unselect all and from there make their indevidual choices.

 

screen4.png

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Sienna
Level 10

Re: Toggle Listbox select all

@souma123

Hi... So I found a workaround for this but without the listbox. You have to use Gallery instead.

 

So here it is

I have created collection which you can replace with your table you are linking with your current listbox. I call it datasource and is collected on first screen 

ClearCollect(Datasource,{id:1, name:"Row1"}, {id:2, name:"Row2"},{id:3, name:"Row3"},{id:4, name:"Row4"})

 

On second screen inserted a blank vertical gallery

 

Set the item property to Datasource

 

Inserted a label into the gallery and expanded the label size to size of the gallery template

 

Set the label OnSelect property to 

If(IsEmpty(Filter(SelecteItems,id=ThisItem.id)), Collect(SelecteItems,ThisItem),Remove(SelecteItems,ThisItem))

 

Set the label Fill property to

If(IsEmpty(Filter(SelecteItems,id=ThisItem.id)), RGBA(0, 0, 0, 0),Color.Blue)

 

Now set toggle OnCheck property to 

Collect(SelecteItems,Datasource)

 

and OnUncheck property to

Clear(SelecteItems)

 

So now you just basically created your own custom listbox with no limits

Enjoy 

View solution in original post

16 REPLIES 16
Community Support Team
Community Support Team

Re: Toggle Listbox select all

Hi @Anonymous,

 

No, currently there is no direct way to configure the control select settings with another control.

You may consider submit this as an idea, under the PowerApps idea forum:

https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

 

Besides, for All selection, we could write if condition to update the record we want with the toggle selection.

For example:

 

If(
   toggle.value=true,
   All-Items,        //Replace All-Items with the ListBox items
   Listbox.selecteditems
)

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
souma123
Level: Powered On

Re: Toggle Listbox select all

Hi, i hope you can help ,

 

Could you please tell me where to write this code, and what is the right syntax (i have 52 choice in my dropdown)

Sienna
Level 10

Re: Toggle Listbox select all

Sienna
Level 10

Re: Toggle Listbox select all

Sorry just tried that.. Listbox is missing DefaultSelectedItem property and Default property takes only texts and not record

souma123
Level: Powered On

Re: Toggle Listbox select all

Thank you Sienna for your Effort , but still waiting of a workaround Smiley Happy or i hope ...

Sienna
Level 10

Re: Toggle Listbox select all

I'm afraid there is no workaround unless they add the DefaultSelectedItems property into a listbox which would take records. It is a shame though

souma123
Level: Powered On

Re: Toggle Listbox select all

 i hope so , really this tool is missing a lot of important features like repeating tables, editable table control......

 

but i'am grathful to you sienna you are so kind Smiley Happy

Sienna
Level 10

Re: Toggle Listbox select all

@souma123

Hi... So I found a workaround for this but without the listbox. You have to use Gallery instead.

 

So here it is

I have created collection which you can replace with your table you are linking with your current listbox. I call it datasource and is collected on first screen 

ClearCollect(Datasource,{id:1, name:"Row1"}, {id:2, name:"Row2"},{id:3, name:"Row3"},{id:4, name:"Row4"})

 

On second screen inserted a blank vertical gallery

 

Set the item property to Datasource

 

Inserted a label into the gallery and expanded the label size to size of the gallery template

 

Set the label OnSelect property to 

If(IsEmpty(Filter(SelecteItems,id=ThisItem.id)), Collect(SelecteItems,ThisItem),Remove(SelecteItems,ThisItem))

 

Set the label Fill property to

If(IsEmpty(Filter(SelecteItems,id=ThisItem.id)), RGBA(0, 0, 0, 0),Color.Blue)

 

Now set toggle OnCheck property to 

Collect(SelecteItems,Datasource)

 

and OnUncheck property to

Clear(SelecteItems)

 

So now you just basically created your own custom listbox with no limits

Enjoy 

View solution in original post

Super User
Super User

Re: Toggle Listbox select all

Nice @Sienna I did something very similar for a customer project. I basically set up the OnVisible for the screen to create a collection with the values from the data source and displayed that in the gallery. If the user pressed the select all button I blew away the collection, recreated it using ForAll, and set the toggle field to true for everything and showed that in the gallery. I had a bunch of other tricks to get to my end solution. 

 

That is the fun of PowerApps. Figuring out how to solve the problems with the provided tools.

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Demo Extravaganza Championship Voting Open

Voting Ends: October 30, 2019!

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 451 members 5,390 guests
Please welcome our newest community members: