Struktur JSON ini digunakan untuk mengkonfigurasi kawalan butang dalam bar status. Struktur kawalan butang JSON boleh disematkan dalam struktur JSON jadual bar status. Struktur ini adalah struktur versi lama, dan platform masih serasi. Disyorkan untuk menggunakan versi terbaru struktur JSON butang. Contoh membina kawalan butang bar status (selepas butang itu dicetuskan dan diklik, kotak pop-up mengandungi kawalan input tunggal, yang dibina melalui medan input):
{
"type": "button",
"cmd": "open",
"name": "opening a position",
"input": {
"name": "number of opening positions",
"type": "number",
"defValue": 1
}
}
Kawalan dalam kotak pop-up dicetuskan dengan mengklik butang bar status kawalan ditetapkan melaluiinput
ataugroup
.
Untuk kawalan butang, tetapan tetap adalah:button
.
jenis
senar
Tetapan jenis butang
kelas
senar
Teks pada butang kawalan, iaitu, nama butang.
nama
senar
Kandungan arahan interaktif yang dihantar ke strategi apabila kawalan butang mencetuskan operasi klik.
cmd
senar
Penerangan kawalan butang. Penerangan dipaparkan apabila tetikus diletakkan pada butang dalam bar status.
Penerangan
senar
Tetapkan butang untuk dilumpuhkan (betul) / diaktifkan (salah).
cacat
bool
Apabila membina butang bar status untuk interaksi, input data juga disokong.GetCommand()
Tambah fungsi.input
Item kepada struktur data JSON kawalan butang dalam bar status untuk mengkonfigurasi kawalan input dalam kotak pop-up yang dipaparkan apabila butang itu dicetuskan.
Sebagai contoh, untuk menetapkan nilaiinput
medan:
{
"name": "Number of opening positions",
"type": "number",
"defValue": 1,
"description": "test",
}
Penerangan setiap medan dalam struktur JSON di atas:
"number"
: kawalan input berangka."string"
: kawalan input rentetan."selected"
: kawalan kotak turun."boolean"
- Pindah kawalan."input": {"name": "Opening quantity", "type": "selected", "defValue": "A|B|C"}
, penerangan teks pilihan kotak turun ditetapkan kepada A, B, C.Untuk medan yang diperluaskan oleh kawalan jenis kotak turun:
{text: "description", value: "value"}
Gunakan medan defValue untuk menetapkan pilihan lalai, yang boleh menjadi pelbagai pilihan.input
JSON
Peraturaninput
medan mengkonfigurasi kawalan dalam kotak pop-up yang muncul selepas butang bar status dicetuskan dengan mengklik.group
daninput
adalah bahawa ia mengkonfigurasi sekumpulan kawalan.group
mempunyai struktur data yang sama denganinput
Sila rujuk penerangan yang berkaitaninput
field.
kumpulan Array
Satu contohclass
nilai struktur JSON butang dalam bar 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
medan denganinput
medan:
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}
Jadual LogStatus LogStatus-btnTypeTwo