How to display the button in the right mouse button panel?
Description of panel-functions in the documentation
For this, in the formatting code, you need to use the prefix p1=: instead of the standard f1=:.
Not all formatting functions work with this prefix, only panel-functions:
panelButtons — places additional buttons on the panel.
panelImg — places an image on the panel.
panelHtml — displays html on the panel.
p0=: panelHtml(html: $strpanel)
strpanel: str`"Physically in Stock<b>" ++ $flat ++ "</b>of which" ++ $block ++ "in reserve."`
flat: select(table: 'goods'; field: 'count'; where: 'id' = #name)
block: select(table: 'goods'; field: 'block'; where: 'id' = #name)
p1=: panelButtons(condition: $block != 0; button: $b1; refresh: true)
b1: rowCreate(field: "text" = "VIEW RESERVES"; field: "code" = "show_block")
p2=: panelButtons(button: $b2; refresh: true)
b2: rowCreate(field: "text" = "VIEW MOVEMENT"; field: "code" = "show_move")
Can panel functions be called from the section f?
No, only from p.
Are sections f and p numbered consecutively?
They have their own separate numbering.
A good practice for code formatting is to place the p section after all the f sections are finished — without mixing them.
Is it possible to display a button by conditions?
Of course, for this in panelButtons and other panel-functions there is a condition parameter.
Does pressing the button refresh the current table?
No — if the button performs an action in the current table, a notification will appear indicating that the table has been modified.
To automatically refresh the table, you need to pass refresh: true in panelButtons.
What kind of row must be passed to form the button?
Mandatory keys are text and code:
=: rowCreate(field: "text" = "VIEW RESERVES"; field: "code" = "show_block")
How to pass a code to "code" for execution?
In code, a string is passed. For example:
=: rowCreate(field: "text" = "BY DEFAULT"; field: "code" = $code)
code: "=: set(table: $#ntn; field: 'field_name' = 100)"
Also, as code, you can pass the name of a field in the current table from which the action code will be taken.
=: rowCreate(field: "text" = "BY DEFAULT"; field: "code" = "field_name")
And the third way, when you want to pass multiline code and have access to it in the same window:
```totum
=: rowCreate(field: "text" = "BY DEFAULT"; field: "code" = $code)
```code:totum
=: set(table: $#ntn; field: 'field_name' = $default)
default: 100
```
This block is saved as text when saved.
If :totum is specified, totum-code highlighting will be activated.
The names of the rows and references to the rows $default are excluded from the current code highlighting and do not intersect with names outside the highlighted area!
What environment variables are passed to the executed code?
$#ntn, $#nci, $#nth, #id (and other lowercase fields).
If you need to pass additional variables into the code, you should pass row in the vars parameter.