I have a component that has a label and a checkbox. I need to count the number of selected checkboxes and remove any checkbox selected. It displays the number selected just fine when only incrementing selections or removing the most recent selection. I cannot properly remove a selection in the middle.
Say I have checkboxes numbered 1, 2, 3, 4, 5. Now say I want to remove number 3 so numbers 4 and 5 need to be renumbered to 3 and 4, respectively but nothing I have come up with works.
Component properties:
ID: text (gets put into selectedCol collection as Selections column)
Number: number
Screen OnVisible:
ClearCollect(numberSelected , {Number:0}); //counts the number of checkboxes selected
ClearCollect(testAlpha,{Number:0,Selections:""});Clear(testAlpha);
ClearCollect(selectedCol,{Number:0,Selections:""});Clear(selectedCol)
Checkbox OnCheck (inside component):
Patch(numberCubesSelected, First(numberCubesSelected), {Number: First(numberCubesSelected).Number+1});
Patch(selectedCol,Defaults(selectedCol),{Number: First(numberCubesSelected).Number, Selections: CheckBoxComp.ID});
Patch(testAlpha,Defaults(testAlpha),{Number: First(numberCubesSelected).Number, Selections: CheckBoxComp.ID});
Checkbox OnUncheck (inside component😞
Patch(numberSelected,First(numberSelected),{Number: First(numberSelected).Number - 1});
Remove(selectedCol,First(Filter(selectedCol,Selections = CheckBoxComp.ID)));
Remove(testAlpha,First(Filter(testAlpha,Selections = CheckBoxComp.ID)));
ForAll(
testAlpha,
If(ThisRecord.Number > CheckBoxComp.numberSelected,
Patch(selectedCol, LookUp(selectedCol, Selections = ThisRecord.Selections),{Number : ThisRecord.Number - 1})//Patch(Col)
}
);
Label:
LookUp(selectedCol, Selections=CheckBoxComp.ID).Number
Any help would be appreciated!

Report
All responses (
Answers (