Struktur JSON ini digunakan untuk mengkonfigurasi kontrol tombol di bilah status. Struktur JSON kontrol tombol dapat disematkan dalam struktur JSON tabel bilah status. Struktur ini adalah struktur versi lama, dan platform masih kompatibel. Contoh membangun kontrol tombol bilah status (setelah tombol dipicu dan diklik, kotak pop-up berisi kontrol input tunggal, yang dibangun melalui bidang input):
{
"type": "button",
"cmd": "open",
"name": "opening a position",
"input": {
"name": "number of opening positions",
"type": "number",
"defValue": 1
}
}
Kontrol di kotak pop-up dipicu dengan mengklik tombol status bar kontrol diatur melaluiinput
ataugroup
.
Untuk kontrol tombol, pengaturan tetap adalah:button
Aku tidak tahu.
jenis
string
Pengaturan jenis tombol
kelas
string
Teks pada tombol kontrol, yaitu, nama tombol.
nama
string
Konten perintah interaktif yang dikirim ke strategi ketika kontrol tombol memicu operasi klik.
cmd
string
Deskripsi kontrol tombol. Deskripsi ditampilkan ketika mouse ditempatkan pada tombol di bilah status.
deskripsi
string
Menetapkan tombol ke disabled (true) / enabled (false).
penyandang cacat
bool
Ketika membangun tombol bilah status untuk interaksi, input data juga didukung.GetCommand()
Fungsi.input
Item ke struktur data JSON dari kontrol tombol di bilah status untuk mengkonfigurasi kontrol input di kotak pop-up yang ditampilkan ketika tombol dipicu.
Sebagai contoh, untuk menetapkan nilai dariinput
bidang:
{
"name": "Number of opening positions",
"type": "number",
"defValue": 1,
"description": "test",
}
Deskripsi setiap bidang dalam struktur JSON di atas:
"number"
: kontrol input numerik."string"
Kontrol input string."selected"
Kontrol kotak drop-down."boolean"
/ Mengganti kontrol."input": {"name": "Opening quantity", "type": "selected", "defValue": "A|B|C"}
, deskripsi teks dari opsi kotak drop-down diatur menjadi A, B, C.Untuk bidang yang diperluas oleh kontrol jenis kotak drop-down:
{text: "description", value: "value"}
Gunakan kolom defValue untuk mengatur opsi default, yang bisa beberapa pilihan.input
JSON
Peraturaninput
field mengkonfigurasi kontrol di kotak pop-up yang muncul setelah tombol status bar dipicu dengan mengklik.group
daninput
adalah bahwa ia mengkonfigurasi sekelompok kontrol.group
memiliki struktur data yang sama denganinput
Silakan lihat deskripsi yang relevan dariinput
field.
kelompok Array
Contoh dariclass
nilai struktur JSON dari tombol di bilah status:
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) + "`")
}
Contoh penggunaangroup
bidang denganinput
bidang:
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}
Tabel LogStatus LogStatus-btnTypeTwo