This JSON structure is used to configure the button control in the status bar. The button control JSON structure can be embedded in the status bar table JSON structure. This structure is an old version structure, and the platform is still compatible. It is recommended to use the latest version of the button JSON structure. Example of constructing a status bar button control (after the button is triggered and clicked, the pop-up box contains a single input control, which is constructed through the input field):
{
"type": "button",
"cmd": "open",
"name": "opening a position",
"input": {
"name": "number of opening positions",
"type": "number",
"defValue": 1
}
}
The controls in the pop-up box triggered by clicking the status bar button control are set through input
or group
.
For button controls, the fixed setting is: button
.
type
string
Button type settings
class
string
The text on the button control, that is, the button name.
name
string
The interactive command content sent to the strategy when the button control triggers a click operation.
cmd
string
The description of the button control. The description is displayed when the mouse is placed on the button in the status bar.
description
string
Sets the button to disabled (true) / enabled (false).
disabled
bool
When constructing a status bar button for interaction, data input is also supported. The interaction command is ultimately captured by the GetCommand()
function. Add the input
item to the JSON data structure of the button control in the status bar to configure the input control in the pop-up box displayed when the button is triggered.
For example, to set the value of the input
field:
{
"name": "Number of opening positions",
"type": "number",
"defValue": 1,
"description": "test",
}
Description of each field in the above JSON structure:
"number"
: numeric input control."string"
: string input control."selected"
: drop-down box control."boolean"
: switch control."input": {"name": "Opening quantity", "type": "selected", "defValue": "A|B|C"}
, the text description of the drop-down box options is set to A, B, C.For the fields extended by the drop-down box type control:
{text: "description", value: "value"}
structure. Use the defValue field to set the default option, which can be multiple selections.input
JSON
The input
field configures a control in the pop-up box that pops up after the status bar button is triggered by clicking. The difference between group
and input
is that it configures a group of controls. The elements in group
have the same data structure as the input
field value. Please refer to the relevant description of the input
field.
group array
An example of the class
value of the JSON structure of a button in the status bar:
function main() {
var table = {
type: "table",
title: "Status bar button style",
cols: ["Default", "Original", "Success", "Information", "Warning", "Danger"],
rows: [
[
{"type":"button", "class": "btn btn-xs btn-default", "name": "Default"},
{"type":"button", "class": "btn btn-xs btn-primary", "name": "Original"},
{"type":"button", "class": "btn btn-xs btn-success", "name": "Success"},
{"type":"button", "class": "btn btn-xs btn-info", "name": "Information"},
{"type":"button", "class": "btn btn-xs btn-warning", "name": "Warning"},
{"type":"button", "class": "btn btn-xs btn-danger", "name": "Danger"}
]
]
}
LogStatus("`" + JSON.stringify(table) + "`")
}
Example of using the group
field with the input
field:
function main() {
// The drop-down box control in the page triggered by the testBtn1 button uses the options field to set options and the defValue field to set the default options. This is different from other examples in this chapter that directly use defValue to set options.
var testBtn1 = {
type: "button",
name: "testBtn1",
cmd: "cmdTestBtn1",
input: {name: "testBtn1ComboBox", type: "selected", options: ["A", "B"], defValue: 1}
}
/*
Status bar button control (set input field implementation) testBtn2 button triggered by the page in the drop-down box control using the options field to set the options, options field in the options field not only supports the string,
it also supports the use of ```{text: "description", value: "value"}``` structure. Use the defValue field to set the default option. The default option can be multiple selection (multiple selection is achieved through an array structure). Multiple selection requires setting the additional field multiple to true.
*/
var testBtn2 = {
type: "button",
name: "testBtn2",
cmd: "cmdTestBtn2",
input: {
name: "testBtn2MultiComboBox",
type: "selected",
description: "Implementing multiple selection in drop-down box",
options: [{text: "Option A", value: "A"}, {text: "Option B", value: "B"}, {text: "Option C", value: "C"}],
defValue: ["A", "C"],
multiple: true
}
}
// Status bar grouping button control (set group field implementation) testBtn3 button triggered by the page in the drop-down box control using the options field to set options, also supports the direct use of defValue set options.
var testBtn3 = {
type: "button",
name: "testBtn3",
cmd: "cmdTestBtn3",
group: [
{name: "comboBox1", label: "labelComboBox1", description: "Drop-down box 1", type: "selected", defValue: 1, options: ["A", "B"]},
{name: "comboBox2", label: "labelComboBox2", description: "Drop-down box 2", type: "selected", defValue: "A|B"},
{name: "comboBox3", label: "labelComboBox3", description: "Drop-down box 3", type: "selected", defValue: [0, 2], multiple: true, options: ["A", "B", "C"]},
{
name: "comboBox4",
label: "labelComboBox4",
description: "Drop-down box 4",
type: "selected",
defValue: ["A", "C"],
multiple: true,
options: [{text: "Option A", value: "A"}, {text: "Option B", value: "B"}, {text: "Option C", value: "C"}, {text: "Option D", value: "D"}]
}
]
}
while (true) {
LogStatus("`" + JSON.stringify(testBtn1) + "`\n", "`" + JSON.stringify(testBtn2) + "`\n", "`" + JSON.stringify(testBtn3) + "`\n")
var cmd = GetCommand()
if (cmd) {
Log(cmd)
}
Sleep(5000)
}
}
{@fun/Log/LogStatus LogStatus}
LogStatus-table LogStatus-btnTypeTwo