PowerApps - Reset Data for Controls
In this post, we look into how to reset the data on the controls in PowerApps.
Basically we come across some scenarios where the controls
data to be set on submitting view, click on clear/reset button and so on.
PowerApps controls have two properties like Default which is
used to set the default value and Reset which is basically used to reset the
data on the control to Default value.
We can’t directly reset the data of a control to default
value like traditional web/windows kind of programming as below. PowerApps use expressions for everything.
TextBox1.Text = “”
We must use the Reset property to reset the data of the
control to Default value.
I have developed a sample PowerApp called Calculator
to demonstrate the same functionality. Please see the screen-shot below.
It contains two TextInput controls to enter the values and
then it has Operators like “+”, “-“, “*” and “/” to do the arithmetic
operations and by default “+” is done against the data that entered into the
form.
The operator can be changed by selecting the appropriate control on the View.
There is a Reset button which is basically to reset the data
on the controls (TextInput) to Default value.
How to Reset the data of TextInput controls on the form.
We have two options to do that. One is using Reset property of the TextInput control to reset and the other is using Reset function.
Option I
We have two options to do that. One is using Reset property of the TextInput control to reset and the other is using Reset function.
Option I
- Set a local variable called resetValues using UpdateContext in Onvisible event.
- Set the Reset value of the Controls which you want to reset on Reset button click to resetValues.
- Set the below expression to OnSelect of Reset button.
Option II
- Set the following expression in OnSelect of Reset button.
This resets the value of the controls (TextInput) to default
value.
Conclusion: Looks the Option II is simple and useful when the View has less controls but Option I would be better option when the View has more controls.
Conclusion: Looks the Option II is simple and useful when the View has less controls but Option I would be better option when the View has more controls.

Comments
Post a Comment