cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
amyharkus1986
New Member

CheckBox tick disappearing after selected

 

 

Hello.

 

I have a gallery that is used to export the selected item to CSV. 

 

On the Checkbox

OnChecked 

Patch(colDWB, ThisItem, {IsChosen: true})

OnUncheck

Patch(colDWB, ThisItem, {IsChosen: false})

 

For testing purpose i have added the field IsChosed to the gallery. 

 

When a checkbox is ticked it is changing this to true as yo can see on record 1321 and 1320

When i refresh the data it is then setting them all back to false 

 

But the strange thing that i can not seem to workout is why the CheckBox is not remaining ticked 

 

amyharkus1986_1-1614774434597.png

So i changed the default on the checkbox to 

If(ThisItem.IsChosen = "true",true, false)

after reading someone else post on here i tried the above to no success. 

 

On a second point id like to add a tick box or button to select all, This way when the user filters to and from on the above filter and it displays the items only for the selected period they can the select all to export all those within the filter.

 

Many Thanks. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User II
Super User II

@amyharkus1986 

Get rid of the If(). A checkbox is only true or false. For a field in your datasource named IsSelected, the default property of the checkbox is simply IsSelected. You are using a collection but if the field is not in the datasource for the collection, then when you "refresh" or probably ClearCollect colDWB the checkbox value resets because it isn't in your datasource.. 

FYI checkboxes are one of only 4 controls that don't require any further specification. The control's name is the value. The others are toggle, slider and rating. 

View solution in original post

3 REPLIES 3
Drrickryp
Super User II
Super User II

@amyharkus1986 

Get rid of the If(). A checkbox is only true or false. For a field in your datasource named IsSelected, the default property of the checkbox is simply IsSelected. You are using a collection but if the field is not in the datasource for the collection, then when you "refresh" or probably ClearCollect colDWB the checkbox value resets because it isn't in your datasource.. 

FYI checkboxes are one of only 4 controls that don't require any further specification. The control's name is the value. The others are toggle, slider and rating. 

View solution in original post

amyharkus1986
New Member

@Drrickryp Thank you, for me it was 

ThisItem.IsChosen

All working now.  

RusselThomas
Microsoft
Microsoft

Hi @amyharkus1986 ,

SPO Yes/No columns are boolean, so you should be able to just use a proper boolean true instead of a text "true" - in which case your default property for the checkbox can be;

ThisItem.IsChosen

You can enable "Check all" and "Uncheck All", but you may also want to add a "Reset All" button, as checking or unchecking all clears the defaults of the current items.  Also, be aware this changes the user experience.  Checking all items using a variable will not trigger their OnCheck: property - that still needs to be done - in which case you may want to introduce an "update all" button as well.  Plus, if you want to reset them back to their default values (what's stored) after using check/uncheck all, "Reset All" helps.  I'm not going to go through all the permutations, but this should get you started;  

Add a checkbox outside the Gallery and call it something like "chkAll". 

Set both it's OnCheck: and OnUncheck: properties to;

UpdateContext({varUsedReset: false})

This ensure that as soon as someone uses it, it resets your varUsedReset variable.

 

Add a Reload icon outside the Gallery and call it something like "icnResetDefaults".

Set it's OnSelect: property to;

UpdateContext({varUsedReset: true})

This will allow you to set all your checkboxes back to what each rows IsChosen value is.

 

Now, set the Default: property of your checkbox inside the gallery to;

If(varUsedReset, ThisItem.IsChosen, Checkbox4.Value)

 

You should notice you can check and uncheck all, and reset back to defaults - but you need to still cater for an update all function as checking all won't update your source this way - unless you want the "check all" checkbox to automatically go and update the source for all items...which could be tedious as users might also want to "Check All" and then go and manually uncheck some items - here again, you may have set a previously unset checkbox with CheckAll, but when they come to uncheck it manually, it will still go and patch the source with a false value, even though it's already blank or false.

You need to play around with the logic to get the experience you want 😊  

Hope this helps,

RT

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (38,641)