Skip to content

Version > 2023.02.14

Field Toolbar

Fields can have additional custom buttons, executing custom functions on click. By giving the button a name, the library tries to find a matching javascript function which will be executed on button click (called by naming convention)

Output

Adding and rendering buttons

Syntax

1
AppGiniHelper.DV.getField(fieldname).getToolbar().add(name, icon, text);

Parameters

  • name
    custom and unique name for the button. Required for onClick-function, called by naming convention
  • icon
    see here
  • text
    Custom button caption

Example

1
2
3
4
5
// file: hooks/TABLENAME-dv.js
// TABLENAME: deliveries
var field = AppGiniHelper.DV.getField("parcelnumber");
var toolbar = field.getToolbar();
var btnTracking = toolbar.add("btnTrack", "flash", "DHL-TRACKING");

Screenshot

You can add multiple buttons per field.

OnClick function

Naming convention for function name:
TABLENAME_FIELDNAME_BUTTONNAME_click

1
2
3
function TABLENAME_FIELDNAME_BUTTONNAME_click(field) {
    // your code here
}

Given...

  • table name = " deliveries "
  • field name = " parcelnumber "
  • button name = " btnTrack "

In this case the expected fuction name is: deliveries_parcelnumber_btnTrack_click

1
2
3
4
function deliveries_parcelnumber_btnTrack_click(field) {
    const trackingNumber = field.getValue();
    // your custom code here
}
By using this "call by naming-convention" method we don't have to attach any click handler. Just write a function with such a name and the automatically attached click-handler will do the rest.

See also