When the toggle is enabled I want my gallery to show the checkboxes that are selected first. This is my gallery - Filter(
collTestMasterData,
If(
IsBlank(ComboBox1.Selected.Result) || ComboBox1.Selected.Result = "All",
true,
C5 in ComboBox1.SelectedItems
) && If(
IsBlank(ComboBox1_1.Selected.Result) || ComboBox1_1.Selected.Result = "All",
true,
C4 in ComboBox1_1.SelectedItems
) && If(
IsBlank(Filter.Text),
true,
Filter.Text in C2
)
&& If(
IsBlank(Search_.Text),
true,
Search_.Text in C7
)). I use a lookup for my checkboxes so the datasource it is patched to always has the updated items. How can I achieve this?
Hi @powerapps890 :
Could you tell me:
I've made a test for your reference:
1\Set the CheckBox's OnCheck property to
Collect(MyCollection,{TheCount:1});/*MyCollection is my custom collection*/
Remove(MyCollection,Last(MyCollection));
Remove(MyCollection,LookUp(MyCollection,ID=ThisItem.ID));
Collect(MyCollection,ThisItem);
Patch(MyCollection,Last(MyCollection),{TheCount:Max(MyCollection,TheCount)+1})
OnUncheck
Remove(MyCollection,LookUp(MyCollection,ID=ThisItem.ID))
2\Set the Gallery's Items property to
Filter(
Sort(collTestMasterData,LookUp(MyCollection,ID=collTestMasterData[@ID]).TheCount),
If(
IsBlank(ComboBox1.Selected.Result) || ComboBox1.Selected.Result = "All",
true,
C5 in ComboBox1.SelectedItems
) &&
If(
IsBlank(ComboBox1_1.Selected.Result) || ComboBox1_1.Selected.Result = "All",
true,
C4 in ComboBox1_1.SelectedItems
) &&
If(
IsBlank(Filter.Text),
true,
Filter.Text in C2
)&&
If(
IsBlank(Search_.Text),
true,
Search_.Text in C7)
)
Best Regards,
Bof
No I only want to bring the checked boxes to the top of the gallery when the toggle is enabled. I mean that I send the checkbox selections directly to the datasource without a submit button and it defaults based on a lookup to that datasource. I just want the user to see their selections at the top when they hit the toggle.
I mention the lookup because I already know how to do this with this code If(Toggle2.Value,
Sort(
Filter(
collTestMasterData,
If(
IsBlank(ComboBox1.Selected.Result) || ComboBox1.Selected.Result = "All",
true,
C5 in ComboBox1.SelectedItems
) && If(
IsBlank(ComboBox1_1.Selected.Result) || ComboBox1_1.Selected.Result = "All",
true,
C4 in ComboBox1_1.SelectedItems
) && If(
IsBlank(Filter.Text),
true,
Filter.Text in C2
)
&& If(
IsBlank(Search_.Text),
true,
Search_.Text in C7
)),C9,Descending),
Filter(
collTestMasterData,
If(
IsBlank(ComboBox1.Selected.Result) || ComboBox1.Selected.Result = "All",
true,
C5 in ComboBox1.SelectedItems
) && If(
IsBlank(ComboBox1_1.Selected.Result) || ComboBox1_1.Selected.Result = "All",
true,
C4 in ComboBox1_1.SelectedItems
) && If(
IsBlank(Filter.Text),
true,
Filter.Text in C2
)
&& If(
IsBlank(Search_.Text),
true,
Search_.Text in C7
))). The problem with this is when you leave the app and come back your previously checked boxes won't filter to the top. The toggle will only work on checkboxes selected during the session you are currently in. @v-bofeng-msft
Hi @powerapps890 :
I may still not understand what you mean.Could you tell me:
If so,I you can try this solution:
1\Set the check box's OnCheck property to
Patch(collTestMasterData,ThisItem,{XXX})
OnUncheck
Patch(collTestMasterData,ThisItem,{XXX})
Best Regards,
Bof
When the toggle is clicked I want only the selected boxes to move to the top. Yes, I do have a column called CheckBox in the datasource. I tried what you said but it is saying that it expected text... CheckBox is a boolean. My need for this is because the list is 300 items long. So they could have a checkbox selected towards the bottom. The toggle will bring the items to the top in succession. The user is only allowed to select 10 which I have coded in. @v-bofeng-msft
Hi @powerapps890 :
First of all, I am not quite clear about the name and data type of the checkbox column in your data source. "{XXX}" needs to be defined according to the situation.
Secondly, if the checkbox column in your data source is of type Yes/No, then you cannot sort according to the order of selection. I suggest you create a "CheckBox" column of number type in the data source.
Finally, please refer to this solution:
1\Set the gallery's items property to:
If(Toggle2.Value,
Sort(XXXX,CheckBox,Descending),
XXXX
)
2\Set the check box's OnCheck property to
Patch(collTestMasterData,ThisItem,{CheckBox:Max(collTestMasterData,CheckBox)+1})
OnUncheck
Patch(collTestMasterData,ThisItem,{CheckBox:0})
Best Regards,
Bof
Sorry I got confused I do have a column I added the uncheck and check code you sent. My problem is the items. If(Toggle2.Value,
Sort(
Filter(
collTestMasterData,
If(
IsBlank(ComboBox1.Selected.Result) || ComboBox1.Selected.Result = "All",
true,
C5 in ComboBox1.SelectedItems
) && If(
IsBlank(ComboBox1_1.Selected.Result) || ComboBox1_1.Selected.Result = "All",
true,
C4 in ComboBox1_1.SelectedItems
) && If(
IsBlank(Filter.Text),
true,
Filter.Text in C2
)
&& If(
IsBlank(Search_.Text),
true,
Search_.Text in C7
)),C9,Descending),
Filter(
collTestMasterData,
If(
IsBlank(ComboBox1.Selected.Result) || ComboBox1.Selected.Result = "All",
true,
C5 in ComboBox1.SelectedItems
) && If(
IsBlank(ComboBox1_1.Selected.Result) || ComboBox1_1.Selected.Result = "All",
true,
C4 in ComboBox1_1.SelectedItems
) && If(
IsBlank(Filter.Text),
true,
Filter.Text in C2
)
&& If(
IsBlank(Search_.Text),
true,
Search_.Text in C7
))) - This is currently my items C9 is CheckBoxColumn btw I tried what you said with this items and it created blank spaces in the gallery. How do I change the Gallery items to make this work? @v-bofeng-msft
Also I tried your way just to see if it would work at all after they originally submitted and now the toggle doesn't work. My whole issue is that the toggle only works if the user clicked that checkbox in the session. I need their old selections from previous days to come to the top when the toggle is hit. @v-bofeng-msft
Hi @powerapps890 :
Sorry, I don’t think I understand what you mean. Could you provide some screenshots?
Best Regards,
Bof
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
199 | |
71 | |
50 | |
42 | |
30 |
User | Count |
---|---|
259 | |
123 | |
92 | |
88 | |
85 |