In DataV, a callback ID is a parameter that is passed to other assets when an asset responds to a user operation or automatically triggers an update. This parameter can be used as a dynamic variable during data query in other assets. This topic uses a ticker board widget as an example to demonstrate the use of callback IDs.
Procedure
Log on DataV console.
Select a visualization application and click Edit to go to the Canvas Editor page.
Add the TicketCard Maker and Title widgets to the canvas.
Select the ticker board component and click the Interactive tab on the right side of the editor.
NoteDataV provides an independent editing area for the callback ID, which is the Interactive panel in the preceding figure. This allows you to use the callback ID feature clearly and quickly.
Select Enable next to Current Value Change. Modify the name of a variable that is bound to the variable.
NoteAfter the variable name is changed to income, the income can be used to obtain the parameter value in the asset that needs to respond to the callback ID.
You can set different variable names for different assets to distinguish between different parameters.
Click the asset whose callback ID you want to respond to. In the data source edit box on the Data page, set: Variable name to the variable that you have configured. For example, you can set the :income parameter. The Title widget is used as an example.
NoteIf the Data Source Type parameter is set to Static Data or CSV File, the callback ID is not supported.
SQL mode
select :income as value
select city from test_id_3 where id = :income
Noteincome
is the callback ID that you configured,value
is a custom field that receives the value of the callback ID.The
id
andcity
are the fields in your database, and thetest_id_3
is the table name of the data table in the database.
API mode
https://api.test?id=:income&city=:mycity
NoteThe
income
andmycity
are the callback IDs that you configured, and theid
andcity
are the fields in your database.
Advanced features
Set custom fields
Select the ticker board widget and click the Data tab.
Click Configure Data Source.
Add a
id
field to the static data with a value of 123.On the Interaction tab, click Create Field.
In the Field column, enter
id
. In the Bound Variable column, enter a variable name.NoteThis variable takes effect only after you specify both the field value and the value of the Bind to Variable parameter.
Set the default value of the callback ID
Specify a request parameter in the URL to set a default value for the callback ID. Example:
http://datav.aliyun.com/screen/000000?myid=123
000000
is the project ID. When you access the visualization application through this URL, the value of the myid
of the callback ID has been set to 123 at the same time when the page is opened. Multiple callback IDs are connected by ampersand (&). In the following example, both the myid
of callback IDs and the default value of income
are set.
http://datav.aliyun.com/screen/000000?myid=123&income=1000
000000
is the project ID.
FAQ
Q: What can I do if I cannot obtain the callback value after I configure the callback ID on the canvas edit page and the data query fails?
A: The canvas editing page cannot trigger the event and obtain the callback value. Therefore, the request fails. You can use one of the following methods to view the return value of the request.
Preview the project. View the return value of the request in the browser console Network, or directly through the asset display mode.
Edit the project. Add test parameters next to the URL of the visual application to test the data.
https://datav.aliyun.com/admin/screen/99999? parameter name=parameter value