Hi @Cinkacinio, 😊
The solution will depend on whether you:
- Only want 1 item selected, which unselects the other item & places all checkboxes on displaymode disabled
- Allow multiple selections but in certain cases only 1 of the options can be selected
Option 1 - Allow only 1 row to be selected
We can track the currently selected item via a variable which will also be used to influence the Default & Displaymode properties:
//Note: save a unique field to the variable e.g. ID
//This approach will only allow 1 selection
//Checkbox OnCheck (save ID)
Set(gblCheckedRow, ThisItem.ID)
//Checkbox OnUncheck (reset var)
Set(gblCheckedRow, Blank())
//Checkbox Default (show selection when the ID matches the current row)
ThisItem.ID = gblCheckedRow
//DisplayMode (Edit when the ID matches the current row or no selection has been made yet)
If(
IsBlank(gblCheckedRow) || ThisItem.ID = gblCheckedRow,
DisplayMode.Edit,
DisplayMode.Disabled
)
Option 2 - Allow multiple rows to be selected with custom displaymode logic
With this approach we will track the selected IDs by saving them to a new collection. In order to implement the conditional row logic we will have to add code to the OnCheck & DisplayMode properties. (e.g. selecting 5 should unselect & disable the checkbox of ID 10)
//Note: save a unique field to the variable e.g. ID
//This approach will allow multiuple selections
//Checkbox OnCheck (collect ID)
Collect(colCheckedRows, ThisItem.ID)
//Checkbox OnUncheck (remove current ID from collection)
RemoveIf(colCheckedRows, Value = ThisItem.ID)
//Checkbox Default (check whether collection contains current ID)
ThisItem.ID in colCheckedRows
//DisplayMode
If(
//Code for the given example
(ThisItem.ID = 10 && 5 in colCheckedRows),
DisplayMode.Disabled,
DisplayMode.Edit
)
//Example should you want to add multiple conditions in the DisplayMode property:
//In addition ID 7 should be disabled when 3 is selected
(ThisItem.ID = 10 && 5 in colCheckedRows) || (ThisItem.ID = 7 && 3 in colCheckedRows)
Logic for unselecting records when a certain ID is checked:
//OnCheck
Collect(colCheckedRows, ThisItem.ID);
//Additional logic for removing 10 from the collection when 5 is selected
If(
ThisItem.ID = 5 && 10 in colCheckedRows,
//If the current item is 5
Remove(colCheckedRows, {Value: 10})
)
//Same example as in the Displaymode property - showcasing how to expand the If function
If(
ThisItem.ID = 5 && 10 in colCheckedRows,
//If the current item is 5
Remove(colCheckedRows, {Value: 10}),
//When 3 is selected, 7 should be removed / unselected
ThisItem.ID = 3 && 7 in colCheckedRows,
Remove(colCheckedRows, {Value: 7})
)
If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.
Thanks!