cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
common_user
Helper IV
Helper IV

Checkbox to selectall in a FILTER gallery

Hi all,

I have a gallery with checkbox in all rows. I have a checkbox to select all items outside gallery too. I try to insert in the default property in the checkbox: checkboxselectedall.value, so if I click on the checkbox it selected all rows.

I have a filter outside gallery (for example to select only row in the gallery that are man), I would like to filter man and then I want to click on checkboxselectedall and select only row with man.

Do you have an idea?

 

Thank you

27 REPLIES 27
common_user
Helper IV
Helper IV

Yes you have understand my request! I would like to give to the user two choices, they can select some rows inside the gallery (with the checkboxes that are in all single rows) or they can select all rows by the checkbox outside the gallery, then they can select a choices with the dropdown (otuside the gallery) and then they can patch all changes by the save button (outside the gallery). So with the SelectAll checkbox it work correctly but it don't work if I select a checkbox inside the gallery. I think that I need to insert some formula on the OnCheck and OnUncheck property inside the checkboxes in the gallery.
Can you help me here for the last task?

I insert a picture to show my request, tell  me if you need more information about this. Thank you so much

common_user_0-1665655775672.png

 

common_user
Helper IV
Helper IV

I insert on the checkbox inside gallery OnCheck property:

Collect(collection; {itemId: ThisItem.ID}) 

 and the follow code OnUncheck property:

Remove(collection; LookUp(colToPatch; itemId = ThisItem.ID))  

I think that I need to integrate my save button code with something follow code

ForAll(
    collection;
    Patch(
        TEST_RUOLI;
        LookUp(
            TEST_RUOLI;
            ID = itemId
        );
        {
            ID: itemId;
            Selezione: Dropdown4_10.Selected
        }
    )
)

 

WiZey
Super User
Super User

I gave you a code sample in my latest post. Did it not work properly?

common_user
Helper IV
Helper IV

No @WiZey don't work, maybe I make something wrong.

I write you all code in my objects.

 

1. I have a button to create a collection, OnSelect I have

ClearCollect(collection; AddColumns(TEST_RUOLI; "Selected"; false))

 2. I have a selectAll checkbox outside gallery with OnSelect property:

UpdateIf(collection;true;{Selected:Self.Value})

3. I have a gallery with items property:

Filter(collection;Sistema=Dropdown5.Selected.Result||Dropdown5.Selected.Result=Blank())

4. Inside gallery I have a chechoxes in every rows with OnCheck property:

Collect(collection; {selectedItems: ThisItem.ID}) 

In OnUncheck property:

Remove(collection; LookUp(collection; selectedItems = ThisItem.ID))  

5.I have a savebutton, OnSelect property:

With({selectedItems:Filter(Gallery3_6.AllItems;Selected)};
  Patch(TEST_RUOLI;
    ShowColumns(selectedItems;"ID");
    ForAll(selectedItems;{ Selezione: Dropdown4_10.Selected})
  )
);;

ClearCollect(collection; AddColumns(TEST_RUOLI; "Selected"; false));;
Notify("Salvataggio eseguito con successo";NotificationType.Success;2000)

 

So if I click on SelectAll checkbox, I choose an option in dropdown and then I click on the save button I can see changes in my sharepoint list, it don't work if i select different checkboxes inside the gallery and then I choose a value from dropdown and save.

WiZey
Super User
Super User

The "OnCheck" and "OnUncheck" of your gallery is wrong. You shouldn't add/remove items, you have to update them to turn them selected/unselected.

 

OnSelect:Patch(collection; ThisItem; {Selected:Self.Value})

 

The code in your save button work with items that have been marked as selected, not if the item is added or removed.

common_user
Helper IV
Helper IV

It's work @WiZey  thank you!

So I have just two bug, it's so strange. Look the follow picture:

common_user_0-1665667657470.png

I click on the checkboxes, I see just a millisecond the flag and then I don't see it but the value is true after click (you can see on the right) so if I change the value from dropbox and I click on save button I can see the changes.

Another strange error is that after I click on the save button, all checkbox value are true as you can see in the follow picture

common_user_1-1665667861857.png

Do you know where is the problem?

WiZey
Super User
Super User

For the first error, can I ask you to check the "Default" property of the checkboxes? The default value should be "ThisItem.Selected".

 

As for the second error, I'm not quite sure what exactly produce this result. Your "ClearCollect()" does create the column with a "false" value though, so it's quite unclear why it would behave this way. I'll need to do some experiments on my side to try and replicate the situation.

common_user
Helper IV
Helper IV

Hi @WiZey , I insert your code in the Default property of the checkboxes, I resolved both problem!

You are incredible! Thank you so much for your patience (I'm sorry if I have not always understood everything quickly but I'm new with this platform).

You are a good teacher and I hope that you will answer me again in the future.

 

Thank you so much

Regards

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,549)