I have a Dropdown control in a Gallery Template that has different colours based on the percentComplete record value. To do that I set the Fill property:
Fill = Switch(percentComplete, 0, Silver, 50, LightSkyBlue, 100, LightGreen)
All good.
However, when I change the selection in the Dropdown, eg to change the task from "In Progress" to "Completed" (ie percent completed from 50 to 100) the item colour does not change.
Is it possible to "repaint" the control, or rerun the Fill function somehow, so the colour changes in line with the selected item?
Thanks,
Murray
Solved! Go to Solution.
OK. Got it working. This is the setup:
The DropDown control is called "TaskStatus" and is in the Gallery Template whose records are Planner Task records which have an integer percentComplete field.
As I understand it (and I am new so this might be incorrect) in PowerApps DropDowns do not have a Value and DisplayText pair that other languages have. I am allowing filtering on the Task Status (percentComplete) via a Combo box so to dry up my code, in the onStart of my app I create a global collection like so:
ClearCollect(collTaskStatus, { p: 0, nn: "Not started" }, { p: 50, nn: "In Progress" }, { p: 100, nn: "Completed" });
then on the TaskStatus dropdown in the Gallery Template the properties are:
Items = collTaskStatus // My global collection as above
Val... = nn // The text value property in the collection
// My Fill which changes colour depending on the value of ThisItem.percentComplete
Fill = Switch(ThisItem.percentComplete, 0, Silver, 50, LightSkyBlue, 100, LightGreen)
onChange =
// Update the server using the UpdateTaskV2 function which expects percentComplete to be a string:
Planner.UpdateTaskV2(
id,
{percentComplete: TaskStatus.SelectedText.nn}
);
// Patch the record in the collection so percentComplete gets set. The Fill "listener" hears that change and updates the Fill colour according to the Switch function as above
Patch(
varServerTasks, // My collection of Task records previously collected
First(
Filter(
varServerTasks,
id = ThisItem.id // id is the task id
)
),
{percentComplete: TaskStatus.SelectedText.p}
);
Thanks! 😁
Hi @Anonymous ,
What is "percentComplete"? Variable?
Do you mean that drop down items are related to percent complete? in another word, what is the relationship between percentComplete record value and drop down items?
The reason that fill doesn't update is that the percentComplete doesn't change when you select the dropdown item.
So you need to set OnChange property of dropdown to set the percentComplete record value when you select the corresponding items.
If(Dropdown1.Selected.Value="In Progress",Set(percentComplete,50),Dropdown1.Selected.Value="Completed",Set(percentComplete,100))
Note: The formula might not be Dropdown1.Selected.Value, it depends on the items and field properties of dropdown.
Hope this helps.
Best regards,
Sik
If my post is helpful for you, please click on “Accept as Solution” to help other members find it more quickly.
OK. Got it working. This is the setup:
The DropDown control is called "TaskStatus" and is in the Gallery Template whose records are Planner Task records which have an integer percentComplete field.
As I understand it (and I am new so this might be incorrect) in PowerApps DropDowns do not have a Value and DisplayText pair that other languages have. I am allowing filtering on the Task Status (percentComplete) via a Combo box so to dry up my code, in the onStart of my app I create a global collection like so:
ClearCollect(collTaskStatus, { p: 0, nn: "Not started" }, { p: 50, nn: "In Progress" }, { p: 100, nn: "Completed" });
then on the TaskStatus dropdown in the Gallery Template the properties are:
Items = collTaskStatus // My global collection as above
Val... = nn // The text value property in the collection
// My Fill which changes colour depending on the value of ThisItem.percentComplete
Fill = Switch(ThisItem.percentComplete, 0, Silver, 50, LightSkyBlue, 100, LightGreen)
onChange =
// Update the server using the UpdateTaskV2 function which expects percentComplete to be a string:
Planner.UpdateTaskV2(
id,
{percentComplete: TaskStatus.SelectedText.nn}
);
// Patch the record in the collection so percentComplete gets set. The Fill "listener" hears that change and updates the Fill colour according to the Switch function as above
Patch(
varServerTasks, // My collection of Task records previously collected
First(
Filter(
varServerTasks,
id = ThisItem.id // id is the task id
)
),
{percentComplete: TaskStatus.SelectedText.p}
);
Thanks! 😁
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
208 | |
49 | |
43 | |
41 | |
36 |
User | Count |
---|---|
291 | |
84 | |
80 | |
80 | |
77 |