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

Checkbox for "Select all" function in Gallery

Hello,

 

I am strugelling setting up "Select All" Checkbox.

I am using Gallery component. In each Item I have a Check box component so user is able to select Items he wants to proceed. But only some items can be proceeded - depending on the Status text. So for some "Statuses" the Check box is hidden (Item should be set as inactive probably, not sure how to set up that).

On the top of the Gallery I have a Check box which should represent "Select all" function so all available Items in the gallery ale selected automatically.

I have also some sorting and searching functions implemented in the Gallery so I need the "Salact all" function to select only Items shown after using all filtering.

 

I am not sure how to set up the top Checkbox so only visible and active items are selected (and stored to a Collection).

 

Example:

Here I filtered GBP transactions only. And when clicking on the Check box on the top 7 items shouls be selected (all GBP items with "Netsuite Ready" status).

 

 

11 REPLIES 11
Highlighted
Community Support Team
Community Support Team

Re: Checkbox for "Select all" function in Gallery

HI @LenkaSalacova ,

Do you want to set up a "Select all" functionality with the "Select all" Checkbox within your app?

 

Based on the needs that you mentioned, I have made a test on my side, please take a try with the following workaround:

I assume that, for "Error" Status the Check box within your Gallery would be hidden. The screenshot as below:9.JPG

 

10.JPG

Set the Default proeprty of the Checkbox control (Checkbox2) within my Gallery to following:

If(Checkbox1.Value = true, true, false)  /* <-- Checkbox1 represents the "Select all" Checkbox above my Gallery */

Set the OnSelect proeprty of the "Collect" button to following:

ClearCollect(
RecordsCollection,
Filter(
Gallery1.AllItems, Checkbox2.Value=true,
Responsible_Officer.DisplayName <> "Test3"
)
)

On your side, you should type:

ClearCollect(
             RecordsCollection, 
             Filter(
                    Gallery1.AllItems, Checkbox2.Value = true, 
                    Status <> "Error"      /* <-- Filter out these items whose corresponding Checkbox control is hidden */
             )
)

Note: I assume that the Status column is a Text type column in your SP list.

If there are other "Status" value, whose Checkbox is hidden, please modify above formula as below:

ClearCollect(
             RecordsCollection, 
             Filter(
                    Gallery1.AllItems, Checkbox2.Value = true, 
                    Status <> "Error",   /* <-- Filter out these items whose corresponding Checkbox control is hidden */
                    Status <> "StatusValue1",
Status <> "StatusValue2",
...
) )

More details about Filter function, please check the following article:

Filter function

 

Best regards,

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

Re: Checkbox for "Select all" function in Gallery

Hello Kris (@v-xida-msft

thanks for your solution. Not sure what I am doing wrogn but it worked for me just partially.

Anyway I feel like I managed to do what I need. I am just not sure if the way how I did iit follows best practise.

 

Checkbox1 means the main one on the top of the Gallery.

Checkbox2 means checkboxes for each Item in the Gallery

SendToNS means Collection I created for collecting Items I need to proceed.

 

1. On Checkbox2 I set Visible property to:  StatusText.Text = "Netsuite Ready"

So the Check box is visible only for Gallery Items with certain statuses.

 

2. On Checkbox2 I set OnCheck property to: Collect(SendToNS,ThisItem)

And UnCheck property to: Remove(SendToNS,ThisItem)

So the Items are added to the Collection even they are selected one by one.

 

3. On Checkbox2 I set Default property to: If(Checkbox2.Visible=true,Checkbox2.Value)

Means status of Checkbox1 is inherited to Checkbox2 but only for Items which are in correct Status.

 

4. On Checkbox1 I set OnCheck property to: ClearCollect(SendToNS,Filter(Gallery.AllItems, StatusText.Text = "Netsuite Ready"))

So the Items selected by this "select all" function are added to the Collection.

Here I would rather use something like this: ClearCollect(SendToNS,Filter(Gallery.AllItems,Checkbox2.Value=true))

But this did not work. The Status Text can change from time to time and I would rather use condition linked to Checkbox2 status than StatusText.

Any idea what I do wrong here?

 

Many thanks!

Lenka

Community Support Team
Community Support Team

Re: Checkbox for "Select all" function in Gallery

Hi @LenkaSalacova ,

Based on the issue that you mentioned, I think this issue may be related to the relationship you don't set up between the Checkbox1 and Checkbox2 control.

 

Based on the solution that you mentioned, I found that when you click "Select all" Checkbox (Checkbox1), the Checkbox (Checkbox2) within your Gallery would not be checked actually. It just display the Checkbox based on the Status value.

As an alternative solution, please take a try with the above solution I provided, bind the Checkbox2 and the Checkbox1 control within your app:

Set the Default proeprty of the Checkbox control (Checkbox2) within my Gallery to following:

If(Checkbox1.Value = true, true, false)  /* <-- Checkbox1 represents the "Select all" Checkbox above my Gallery */

Set OnCheck property of the Checkbox1 to following:

ClearCollect(
SendToNS,
Filter(
Gallery.AllItems,
Checkbox2.Value = true,
StatusText.Text = "Netsuite Ready"
)
)

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

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

Re: Checkbox for "Select all" function in Gallery

Hello Kris (@v-xida-msft ),

I tried what you suggested, the thing is the Items are not stored to the Collection.

I feel like the condition "Checkbox2.Value = true," is not taken into account even in mine or your solution.

Lenka

 

Super User
Super User

Re: Checkbox for "Select all" function in Gallery

Just use an if statement so you would say if checkbox is visible and if the value is true then...take whatever action. 

 

For your checkbox that you want to do "Select All" I would use the UpdateContext and set a variable so when the checkbox is checked it does UpdateContext({SelectAll:true}) and then for the default value of the checkbox would be If(Status.Value="Whatever" && SelectAll,true, false). If you do this route remember to also have the opposite for when the check box is unchecked...it would be UpdateContext({SelectAll:false}).

 

For hiding ones of a certain status just put a Filter on your gallery. If they are filtered out they are not included when you patch.

 

 

Community Support Team
Community Support Team

Re: Checkbox for "Select all" function in Gallery

Hi @LenkaSalacova ,

I have made a test on my side, and don't have the issue that you mentioned.

Please check if all Checkbox2 are checked within your Gallery when you checked the Checkbox1 ("Select all"  Checkbox) on your side.

 

Please take a try to set the OnSelect property of your Checkbox1 to following:

If(
   Checkbox1.Value = true,
   ClearCollect(
             SendToNS,
              Filter(
                      Gallery.AllItems,
                      Checkbox2.Value = true,
                      StatusText.Text = "Netsuite Ready"
              )
     )
)

In addition, please also consider take a try to add another button control within your app, set the OnSelect property to following:

ClearCollect(
             SendToNS,
              Filter(
                      Gallery.AllItems,
                      Checkbox2.Value = true,
                      StatusText.Text = "Netsuite Ready"
              )
)

then check if the SendToNS collection is populated with values.

 

If the issue still exists, please consider take a try to re-create your app based on my solution step by step, then check if the issue still exists.

 

Best regards,

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

Re: Checkbox for "Select all" function in Gallery

Hi @v-xida-msft ,

 

This solution works for me but I do not feel like it is the best way.

The thing it I have 2 conditions linked to the StatusText. The first one is in "Visible" property on Checkbox2: StatusText.Text = "Netsuite Ready"

So I think the condition in "OnCheck" property of Checkbox1 should be:  
If(
Checkbox1.Value = true,
ClearCollect(
SendToNS,
Filter(
Gallery.AllItems,
Checkbox2.Value = true,
Checkbox2.Visible = true )))

 

The only difference here is using "Visible" property of Checkbox2 instead of StatusText.Text Value. But using "Visible" property this way is not valid. Any idea how to set the condition using Checkbox2 visibility?

 

Thanks!

Lenka

Super User
Super User

Re: Checkbox for "Select all" function in Gallery

I think I am understanding you correctly...if so:

 

Instead of putting the OnCheck to set the visible true...make it do an UpdateContext({showCheckBox2:true}) and then you can refer to the variable by doing the OnVisible of Checkbox 2 is showCheckBox2.

 

I often use the disabled property instead of the visible but I use this a code a lot on mine because I have some that a second is contengent on the first and so I also make the first one be disabled when they click on the second and several other rules like that. 

 

If you do use the variable option make sure you also put on the UnCheck to make it false.

LenkaSalacova
Level: Powered On

Re: Checkbox for "Select all" function in Gallery

Hello,

 

I redone the logic a litle bit because previous solution was not stable and it completely stopped working when ani filter in the Gallery was chenged.

 

So I have a column where with bolean values to control which rows were already selected and which not. So instead of controlling of true or valse values of Checkbox5 I control value in the bolean column.

Like in OnCheck property of Checkbox5 I have: Patch(SendToNS_2, ThisItem, {InternalID: 1})

and in OnUncheck property I have: Patch(SendToNS_2, ThisItem, {InternalID: 0})

and in Default and Reset properties I have: If(InternalID=1, true, false)

This works perfectly.

 

The thing is how to make Checkbox6 to check all items listed in the Gallery.

In OnSelect property of Checkbox6 I have: Patch(SendToNS_2, RDF_Gallery_1.Selected, {InternalID: 1})

That works perfectly for the one Selected row. But I do not know how to set this logic for all items listed in the Gallery (not only for the selected one).

I tried: Patch(SendToNS_2, RDF_Gallery_1.AllItems, {InternalID: 1})

But it seems like "AllItems" does not work here ://