Last active
July 27, 2023 15:15
-
-
Save andrew-grischenko/bce9896ee736d4db699fea336bf10a11 to your computer and use it in GitHub Desktop.
Power Apps PCF - Reset component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
export class SomeComponent implements ComponentFramework.StandardControl<IInputs, IOutputs> { | |
private has_been_reset: boolean; | |
... | |
public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container:HTMLDivElement) | |
{ | |
this.has_been_reset = false; | |
... | |
} | |
... | |
public updateView(context: ComponentFramework.Context<IInputs>): void | |
{ | |
if(context.parameters.Reset.raw && !this.has_been_reset){ | |
this.has_been_reset = true; | |
// do the clean up logic here | |
... | |
} else | |
// Technically, this will be done on ANY change of a property, which we don't care about as long as | |
// it's also done on setting of the Reset property | |
this.has_been_reset = false; | |
... | |
} | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<manifest> | |
<control ...> | |
<property name="Reset" display-name-key="Reset" description-key="Reset from start" of-type="TwoOptions" usage="input" required="false" default-value="false"/> | |
... | |
</control> | |
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Declare in a code (on screen visible or something like that) a dummy reset variable | |
Set(DummyResetVariable, false); | |
// Bind your control's Reset property to a dummy reset variable | |
// In the Component's inspector set value of the property Reset to | |
DummyResetVariable | |
// Now when you need to reset a control, set the dummy variable | |
Set(DummyResetVariable, true); | |
Set(DummyResetVariable, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Andrew,
default-value in manifest doesn't appear to load false when using the pcf watch
^^ updated. default-value is only support by model-driven and not canvasApp