Custom Pages use different controls than Canvas Apps

 Those who've worked with canvas apps and custom pages have probably noticed that there are some controls which are only available in canvas apps, like pen input, drop down and address input, but today I noticed that one a particular control that has been replaced.
More specifically, the text input control.

Canvas Apps has a control called Text Input, it's a basic input box with some nice properties, like Reset, and default value.
Custom Pages does not have Text Input, they instead have something called a Text Box, and it does not have the abovementioned properties.

Why is that important? Well say you've got a gallery and you use some controls to input text there, let's say you use it to be able to update multiple rows at the same time. Now you want to have any function to modify several items at the same time, in this example say we want a CLEAR button which reverts the changes you have done since last save.
With a Text Input, you can simply put a variable in the Reset property like so:

Next you add a button and put this in the OnSelect formula:

What this does is set "reset" to true, which will revert the value in the text box to the default value. Any modifications done in the text boxes that aren't reflected in the data source is now reverted for all rows.

So what about custom pages?

Unfortunately the Text Box found in custom pages do not have a reset or default value. That means the only way to edit the values in these text boxes is to edit the data source. This leads to an anti-pattern, where instead of using the actual data source to list items we start using collections to store the data. This is really ineffective and can slow down the app considerably.

To reproduce the same functionality as above, you would need to do the following.
1: Create a collection used as input for the gallery, in this case I added it in app start

2: Next I set the gallery items to that variable

3: Create a clear button, where I do another ClearCollect identical to the one in app start

Now I can reset the changes since last save, but it will also reload all the data, which can can severely affect the performance. Additionally, having data in collections can cause discrepancy between the collected and stored data, especially if they are used in several components.

Comments

Popular posts from this blog

Migrate Power Pages to enhanced data model

Using upsert in power fx with multiple records

Adding new assets to a Power Pages solution