Using variables in a low-code app
In this tutorial, you will learn how to create a variable and dynamically change its value through a header bar, allowing it to be used as an element state filter within a query.
By the end of this tutorial, you will have a functional low-code app that allows users to dynamically filter elements based on their state.
Estimated duration: 15 minutes.
Note
- This tutorial uses DataMiner web version 10.5.1.
- Variables have been available since DataMiner web version 10.4.12, and support for dynamic value changes was introduced in version 10.5.1.
Tip
See also: Kata #58: Low-Code Apps - Introducing Variables on DataMiner Dojo
Prerequisites
DataMiner server version 10.4.0 or higher
DataMiner web version 10.5.1 or higher
Overview
Step 2: Create a 'Get elements' query filtered by the variable
Step 3: Add buttons to modify the variable and filter elements
Step 1: Create a variable
In the Data pane on the right, expand the Variables item and click the "+" icon to start creating a new variable.
In the Name box, enter a descriptive name for the variable.
Select Text from the Type dropdown list.
Ensure the Read-only option is disabled so the variable can be changed later.
Click the
button to stop editing the variable.
Step 2: Create a 'Get elements' query filtered by the variable
In this step, you will create a query that retrieves elements in your DataMiner System filtered by the variable created in step 1.
Create a query:
In the Data pane, Expand the Queries item and click the "+" icon to start creating a new query.
In the Name box, enter a name for the query.
Select Get elements as the data source.
Apply a Filter query operator:
Select Filter from the Operator dropdown list.
Choose State as the column to filter.
Select equals as the filter method.
Under Value, click the
button.
From the Data dropdown list, select the variable you created in step 1.
Under Empty data shows, select everything.
Click Link in the lower right corner.
Tip
Click the
button to stop editing the query.
Add a table component to the app.
Drag the newly created query from the Data pane onto the table component.
The table now displays an overview of all elements in your DataMiner System.
Step 3: Add buttons to modify the variable and filter elements
Currently, all elements are displayed in the table. To allow filtering, you will add buttons to the header bar that modify the variable's value, thereby updating the query dynamically.
Click the header bar toggle button.
Add a button to filter for active elements:
Click the "+" on the left side of the header bar.
Enter
Active
as the button label.Expand the Events item and select Configure actions.
Select Change variable from the dropdown list.
From the Variable dropdown list, select the variable you created in step 1.
Enter
Active
as the new value.Click Ok.
Add a button to filter for stopped elements:
Click the "+" on the left side of the header bar.
Enter
Stopped
as the button label.Expand the Events item and select Configure actions.
Select Change variable from the dropdown list.
From the Variable dropdown list, select the variable you created in step 1.
Enter
Stopped
as the new value.Click Ok.
Publish the app by clicking the
button in the top-right corner of the low-code app header bar.
Your app is now functional. By default, it displays all elements in your DataMiner System, but you can use the buttons in the header bar to filter the list to show only active or stopped elements.