A button control that lets the user add one or more pre-populated new rows to a specific table in the form.
Properties
Property | Type | Description |
---|---|---|
label (read-only) | string |
Specifies the text that will be displayed as the label of the control. |
records (required) | recordset | Specifies zero or more rows that will be added to the recordset of the target table control when the user clicks the button. |
text | string | Specifies the text to be displayed on the control in the form. The default
text is "Add" .
|
Traits
Trait | Description |
---|---|
declarations |
A collection of zero or more variable declarations (let elements) that can be referenced in solution-wide query expressions. |
validation |
A collection of zero or more validation rules (validator elements) that evaluate user input in the control at
runtime, and prevent the user from submitting the form if the |
Remarks
The order, type, and name of the fields in the records that the
addbutton
's records
property returns must conform to those
defined by the targeted table control's recordset
property, but there are no
limits to the number of rows that an addbutton
can add to a
table
control.
... <table id="tableFoo" recordset='{TABLE height, width (1080, 1920; 768, 1366; 1024, 1280)}' record="foo"> <row> <cell> <textview text='{TOSTRING(foo.width)}'/> </cell> <cell> <textview text='{TOSTRING(foo.height)}'/> </cell> </row> </table> <addbutton table="tableFoo"records='{TABLE height, width
(800, 1280;
768, 1024;
600, 800)}'
text="Add more than one row to the table"/> ...
Figure 225. The records
property of the Add more than one
row...
addbutton
control returns three records that match the structure of
tableFoo
's recordset
Since the fields that its records
property returns all match those in
the targeted table
control's recordset
, there is nothing
stopping the addbutton
from adding any number of rows to
tableFoo
.
The rows added by an addbutton
are always appended at the end of the target
table's recordset, even if the target table's recordset
query includes an
ORDER BY
clause.
The addbutton
's table
field is a
reference to the table that the button targets. If the addbutton
and the
target table are not in the same scope, you must enter the
target table's dot-separated qualified identifier.
There is no limit on the number of addbutton
controls that you can associate
with the same table control.
When the user adds one or more rows to a table control using an addbutton
,
the target table control's recordset
query is not re-evaluated, and so any
rows that the target table previously had are not discarded.
However, if the target table's recordset
query is later
re-evaluated for any reason, the rows that were added with an addbutton
, as
well as any other user input in the table will be
discarded.
... <textbox label="Only show items that start with" id="filterbox"/> <table id="reEval" label="Fruit and veg I like" recordset='{SELECT f.fruitName FROM (TABLE fruitName("apple"; "beetroot"; "currant"; "durian"; "elderberry")) f WHERE f.fruitName LIKE filterbox.text || "%"}' record="reEval"> <row> <cell> <textbox text='{reEval.fruitName}'/> </cell> </row> </table> <addbutton table="reEval" records='{TABLE fruitName("eggplant")}' text="Add an eggplant"/> ...
Figure 227. The Fruit and veg I like table after the user added two
eggplant items with the Add an eggplant
addbutton
When the user filters the reEval
table
control by entering a string in the filterbox
textbox
, its recordset
is re-evaluated, and the records that
were appended with the addbutton
are discarded.
Figure 228. No matter what filter criteria the user enters in the filterbox
textbox, the eggplant entries are lost
Sample
... <textbox id="textFoo" label="Text for column 1:" /> <numberbox id="textBar" numberFormat='{decimalSeparator:"."}' label="An integer for column 2:" /> <numberbox id="textBaz" numberFormat='{decimalSeparator:"."}' float="true" label="A float for column 3:" /> <addbutton table="empty" records='{SELECT textFoo.text column_1, textBar.number column_2, textBaz.number column_3}' text="Populate the table"/> <table id="target" recordset='{TABLE column_1, column_2, column_3 ("Heidegger", 42, 3.14)}' record="target"> <row> <cell> <textview text='{target.column_1}'/> </cell> <cell> <textview text='{TOSTRING(target.column_2)}'/> </cell> <cell> <textview text='{TOSTRING(target.column_3)}'/> </cell> </row> </table> ...
A workflow script running in the Mobilengine Cloud would access the submission of the form above in the format below:
{... textFoo: {text: "axolotl"}, textBar: {number: 23}, textBaz: {number: 0.67}, ...}
See the workflow script reference guide for more details on data type mapping.