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 Memorable Member
Memorable Member

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
Community Support

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 Helper I
Helper I

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 Memorable Member
Memorable Member

Re: Toggle Listbox select all

Sienna Memorable Member
Memorable Member

Re: Toggle Listbox select all

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

souma123 Helper I
Helper I

Re: Toggle Listbox select all

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

Sienna Memorable Member
Memorable Member

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 Helper I
Helper I

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 🙂

Sienna Memorable Member
Memorable Member

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
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (5,855)