LogStatus-btnTypeOne
This JSON structure is used to configure button controls in the status bar. The button control JSON structure can be embedded into the status bar table JSON structure. This is a legacy version structure that the platform still supports for compatibility, but it is recommended to use the latest version of the button JSON structure.
Status bar button control construction example (after button click trigger, the popup contains a single input control, constructed through the input field):
json
{
"type": "button",
"cmd": "open",
"name": "Open Position",
"input": {
"name": "Position Size",
"type": "number",
"defValue": 1
}
}
The controls in the popup triggered by clicking the status bar button are configured through the input or group fields.
Attributes
| Name | Type | Description |
type | string | For button controls, fixed as: |
class | string | Button type setting. |
name | string | The text displayed on the button control, i.e., the button name. |
cmd | string | The interactive command content sent to the strategy when the button control triggers a click operation. |
description | string | Description information for the button control. This description is displayed when the mouse hovers over the button in the status bar. |
disabled | bool | Set the button as disabled (true) or enabled (false). |
input | JSON | When constructing status bar buttons for interaction, data input is supported. The interaction command is ultimately captured by the
Description of each field in the above JSON structure:
Extended fields for dropdown type controls:
|
group | array | The |
See Also
Remarks
Example of class attribute values for button JSON structure in status bar:
javascript
function main() {
var table = {
type: "table",
title: "Status Bar Button Styles",
cols: ["Default", "Primary", "Success", "Info", "Warning", "Danger"],
rows: [
[
{"type":"button", "class": "btn btn-xs btn-default", "name": "Default"},
{"type":"button", "class": "btn btn-xs btn-primary", "name": "Primary"},
{"type":"button", "class": "btn btn-xs btn-success", "name": "Success"},
{"type":"button", "class": "btn btn-xs btn-info", "name": "Info"},
{"type":"button", "class": "btn btn-xs btn-warning", "name": "Warning"},
{"type":"button", "class": "btn btn-xs btn-danger", "name": "Danger"}
]
]
}
LogStatus("`" + JSON.stringify(table) + "`")
}
group field and input field usage example:
javascript
function main() {
// Status bar button control (implemented with input field) - The dropdown control on the page triggered by testBtn1 button uses options field to set options and defValue field to set default option. This differs 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 (implemented with input field) - The dropdown control on the page triggered by testBtn2 button uses options field to set options. The options field supports not only strings,
but also ```{text: "description", value: "value"}``` structure. Use defValue field to set default option, which can be multiple selections (implemented through array structure). Multiple selection requires setting additional field multiple to true.
*/
var testBtn2 = {
type: "button",
name: "testBtn2",
cmd: "cmdTestBtn2",
input: {
name: "testBtn2MultiComboBox",
type: "selected",
description: "Implement dropdown multi-select",
options: [{text: "Option A", value: "A"}, {text: "Option B", value: "B"}, {text: "Option C", value: "C"}],
defValue: ["A", "C"],
multiple: true
}
}
// Status bar grouped button control (implemented with group field) - The dropdown control on the page triggered by testBtn3 button uses options field to set options, and also supports directly using defValue to set options.
var testBtn3 = {
type: "button",
name: "testBtn3",
cmd: "cmdTestBtn3",
group: [
{name: "comboBox1", label: "labelComboBox1", description: "Dropdown 1", type: "selected", defValue: 1, options: ["A", "B"]},
{name: "comboBox2", label: "labelComboBox2", description: "Dropdown 2", type: "selected", defValue: "A|B"},
{name: "comboBox3", label: "labelComboBox3", description: "Dropdown 3", type: "selected", defValue: [0, 2], multiple: true, options: ["A", "B", "C"]},
{
name: "comboBox4",
label: "labelComboBox4",
description: "Dropdown 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)
}
}