Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
This page is for application designers who want to configure parts of a screen to be visible in specific conditions.
A toggle component is a switch that returns true or false, when it is enabled or disabled respectively. Its useful for showing and hiding content based on whether it is enabled or not.
Setup
- Toggles are available from the Toggles section of the palette.
- Drag one onto your screen.
- Its value is now available using the syntax
_form.ToggleName
- Its value is now available using the syntax
- The state of the toggle can now be accessed by any object on the screen within its formatting rule. see Applying Formatting Rules. When the toggle is enabled,
_form.ToggleName,
will return true which means your formatting rule will be applied.
Examples
Switch View Types
In our Demo CRM app available from acts as a switch to represent:
- on/off
- enabled/disabled
- show/hide
When the application user changes the state of the switch, you can read the state change in a formatting rule and use it to change other components on the screen. For example, you can use a toggle to show or hide part of a screen.
There are prebuilt toggle switches available in the
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
The steps to use a toggle are:
- From the palette, drag a toggle onto the screen canvas.
- For another component on the screen, configure:
- the style to use when the toggle is disabled/off.
- and a formatting rule to use when the toggle is enabled/on; see Applying Formatting Rules.
- In the formatting rule set:
- Rule Expression to
_form.ToggleName
When the toggle is:- enabled/on, it returns true
- disabled/off, it returns false
- Style to the style you want to use when the expression returns true.
- Rule Expression to
Example to Switch View Type
In our Demo CRM application, which is available from the Learning Centre downloads, we have a toggle switch between a card view and a grid view. This is illustrated below:.
Card ViewWhen the Grid View toggle is disabled, the screen displays a card view of the data:
Grid
ViewWhen the Grid View toggle is enabled, PhixFlow displays a grid view of the data:
Both data views exist in the same location on the screen, but their formatting rules hide them depending on the toggle state.
The screenshot below shows the card view's formatting rule. When _form.GridView
returns true
we apply the Hidden style to the card view.