# Variable call-back
In OneNET View 2.0, callback variable
means the parameter transmitted by a component to another component or data source in response to user actions or upon automatic triggering of updating.
When a callback variable is used in a data source, the value of this variable can be used as a dynamic variable in data query.
For example, paging is needed in some scenes. At this time, we can transmit the page
parameter in the paging component. After API interface receives this page
variable, dynamic query of the corresponding page data can be performed.
Once a component is selected, the set
area will appear in the right of the editor. The callback variable can be set in the interaction
tab in this area.
Each callback variable is provided with an independent enable
switch.
You can modify the variable name in “bound to variable” based on the application.
As shown on the figure, we bind the value of the text component to variablecity
. When the text component is clicked (for interactive events without special instructions, the default is the component click event), a variable namedcity
whose value is the value of the text component (“Chongqing” on the figure) will be set in the item.
The query parameters already occupied by the system cannot be set as callback variables, which at this time include:
id
,shareCode
,debug
We can set the callback variable and the respective default value by setting the query
parameter in the url. For example.
http://open.iot.10086.cn/view/main/#/view2d?id=5e68872cb390c9c2e9af7ba9&hello=lingc
In case of access via this url, when the page is loaded, the value of the callback variable hello
has been set to lingc
.
The \& symbol is used for connection between callback variables, for example
http://open.iot.10086.cn/view/main/#/view2d?id=5e68872cb390c9c2e9af7ba9&hello=lingc&city=chongqing
The default values of callback hello
and city
are set at the same time.
We provide the “view variable” buttons on edit page and browse page (except the share page). After clicking the variable button, the current variable and its value of the item will appear.
Used in data source: the corresponding callback variable can be used as the variable name (e.g. city).
In API data source, Path, Query, Header and Body all support setting the key value with the callback variable. For example: herein
http://apis.juhe.cn/simpleWeather/query?city=:city&key=73a0b2fe78c2e9d07df67ca848213ad7
In actual request, :city
will be substituted with the specific value of the callback variable.
With the support of callback variables, together with OneNET data source, we can switch and observe the data of multiple OneNET devices on the same large screen.
After setting the device variable, the value (if any) of the variable will be directly used as the device ID. After setting the data stream variable, the value (if any) of variable will be directly used as the data stream ID.
For example: For the OneNET data source on the above figure, the device and data stream are bound with callback variables. The value (if any) of the callback variable is preferred; otherwise, the device and data stream selected in the drop-down box will be adopted.
Used in the filter: the callback variable can be accessed through the parameter “variables” in the filter.