Custom Delegates
You build Apps in Lianja App Builder visually using the Page Builder.
If you have not yet done so please read Understanding the Lianja Architecture and also Understanding ART to better understand this article.
Select the "Pages" workspace if it is not already selected.
Select the "Attributes" Tab in the App Inspector if it is not already selected.
Click the second column in the "Custom Delegates" grid.
You will see a "..." button. Click that to switch into the Script Editor to edit the delegate code.
An App consists of pages. Pages are made up of Sections. Form sections are made up of FormItems. We call these collectively "UI Elements" or "Visual Elements".
You adjust the appearance and behavior of each UI Element in the Attributes Tab of the App Inspector or in the Page Builder Assistant.
Delegates are scripting language independent event handlers for specific actions that may occur related to a UI Element.
Here in the Attributes Tab:
and here in the Assistant:
Note that clicking on a delegate name in the Assistant opens the Script Editor in a floating window, rather than switching to the Apps workspace.
Contents
- 1 Scripting Language
- 2 Custom Library
- 3 Delegates
- 3.1 Activate
- 3.2 After Data Changed
- 3.3 After Data Create
- 3.4 After Data Delete
- 3.5 After Data Update
- 3.6 After Edit
- 3.7 After Refresh
- 3.8 After Row Change
- 3.9 After Row/Col Change
- 3.10 After Save
- 3.11 Before Data Create
- 3.12 Before Data Delete
- 3.13 Before Data Update
- 3.14 Before Edit
- 3.15 Before preview
- 3.16 Before Refresh
- 3.17 Before Row/Col Change
- 3.18 Before Save
- 3.19 Change
- 3.20 Click
- 3.21 Collapsed
- 3.22 Connection State Changed
- 3.23 Context Menu
- 3.24 Custom footer menu
- 3.25 Custom options menu
- 3.26 Custom settings menu
- 3.27 Custom search command
- 3.28 Custom section menu
- 3.29 Data Changed
- 3.30 Database changed
- 3.31 Data Producer
- 3.32 Deactivate
- 3.33 Default Action
- 3.34 Destroy
- 3.35 Device Motion Changed
- 3.36 Dialog button delegate
- 3.37 Dialog button menu delegate
- 3.38 Double click
- 3.39 Enabled When
- 3.40 Expanded
- 3.41 File System Watcher
- 3.42 Gestures
- 3.43 Got Focus
- 3.44 Hotkey
- 3.45 Inactive
- 3.46 Init
- 3.47 Init Form Defaults
- 3.48 Init Form
- 3.49 Instant Search
- 3.50 Instant Selection
- 3.51 Interactive Change
- 3.52 Link Click
- 3.53 Load
- 3.54 Lost Focus
- 3.55 Middle Click
- 3.56 Mouse Down
- 3.57 Mouse Enter
- 3.58 Mouse Leave
- 3.59 Mouse Move
- 3.60 Mouse Up
- 3.61 Orientation Changed
- 3.62 Pan gesture
- 3.63 Parent data changed
- 3.64 Pinch gesture
- 3.65 Print
- 3.66 Ready
- 3.67 Refresh
- 3.68 Resize
- 3.69 Resized
- 3.70 Right Click
- 3.71 Row/Col Change
- 3.72 Selection Changed
- 3.73 Sort
- 3.74 State Changed
- 3.75 Swipe down gesture
- 3.76 Swipe left gesture
- 3.77 Swipe right gesture
- 3.78 Swipe up gesture
- 3.79 Tap gesture
- 3.80 Tap and hold gesture
- 3.81 Text Translator
- 3.82 Timer
- 3.83 Unload
- 3.84 Valid When
- 3.85 Visible When
- 4 Event Sequences
- 5 Other Delegates
- 6 Inline Delegates
Scripting Language
The scripting language for custom code.
Supported by
App, Page, all Sections (except Page Center)
Notes
Available choices are:
Scripting Language | Notes |
---|---|
Inherit | This is the default. The scripting language is inherited from the parent container, i.e. Section inherits from Page, Page from App. For the App, the scripting language must be specified. |
Recital | Desktop Apps only. |
Visual FoxPro | Desktop Apps only. |
Python | Desktop Apps only. |
JavaScript | Desktop/Web/Mobile Apps. |
TypeScript | Desktop/Web/Mobile Apps. |
Babel | Desktop/Web/Mobile Apps. |
PHP | Desktop Apps only. |
From Lianja v5.3 JavaScript delegates can now reference the UI element for the delegate using This (note upper case 'T'), thisElement or thiselement.
Custom Library
The name of the custom library containing the delegate code. This library is loaded when the App is opened.
Supported by
App, Page, All Sections (except Page Center).
Notes
- A filename can be entered.
- Clicking the [...] button will automatically create a file. The file is created with a name based on the name of the current container and with a file extension to match the selected scripting language, e.g. lib_page1_section1.js for section1 in page1 with JavaScript selected. The file is automatically opened in the Script Editor in the Apps workspace.
- There is no need to specify a Custom Library. When the [...] is clicked next to a Custom Delegate, e.g. Activate, the hierarchy is checked for an existing Custom Library: Section, Page, App and a file automatically created for the current container if none exists. As before, the file is automatically opened in the Script Editor in the Apps workspace.
- Note that if you want to have all the event delegate code stored in a single Custom Library, just click the [...] for the App Custom Library and any subsequently added event delegate code will be added to the automatically created file.
Delegates
Activate
The delegate for the activate event.
Supported by
App, Page, All Sections (except Page Center), Checklistview Gadget, Grid Gadget, Listview Gadget, Treeview Gadget, Form Section Fields, Canvas Section Advanced Controls
Notes
- Activate is the fourth of the four key events to be called when an App is opened:
- Init
- Load
- Ready
- Activate
- See Opening an App for more details.
- The Activate delegate is also called when moving between Pages.
- See Navigating between Pages for more details.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
After Data Changed
The delegate for the dataChanged event called after the data is read on opening the App, navigating between records or after data modification operations.
Supported by
Attachments Section, Canvas Section, Form Section, Grid Section, Image Strip Section, Grid Gadget
Notes
- See Event Delegate Sequences for more details.
- See Data Changed for the Form Section Field and Canvas Section Advanced Control dataChanged event delegate.
- For Attachments Sectiona, Grid Sections and Image Strip Sections, the Data Changed event delegate is only called when the Section is the primary Section on the Page (tied to the Page actionbar). When they are related to a parent Section, their Parent Data Changed event delegate is called.
After Data Create
The delegate for the afterCreated event.
Supported by
Attachments Section, Canvas Section, Form Section, Grid Section, Grid Gadget
Notes
- Called after a new record has been added.
- See Adding a new record for more details.
After Data Delete
The delegate for the afterDelete event.
Supported by
Attachments Section, Canvas Section, Form Section, Grid Section, Grid Gadget
Notes
- Called after a record has been deleted.
- See Deleting a record for more details.
After Data Update
The delegate for the afterUpdate event.
Supported by
Attachments Section, Canvas Section, Form Section, Grid Section, Grid Gadget
Notes
- See Updating a record for more details.
After Edit
The delegate for the afterEdit event.
Supported by
Attachments Section, Canvas Section, Custom Section, Form Section, Grid Section, Image Strip Section, Notifications Section, TabView Section, Timeline Section, Webview Section
Notes
- Introduced in v5.4.
- This is called when coming out of edit mode (after the Save/Done or Cancel button is clicked or the edit(), save() or cancel() method called).
- It can be used, for example, to show the Navigation Panel again after the data edit is complete.
- The Navigation Panel visibility can be controlled using the Lianja system object methods: Lianja.showNavigationPanel(), Lianja.showNavigationPanel() or Lianja.showNavigationPanel() or the hidenavigationpanel and shownavigationpanel actions with the Lianja.showDocument() method or showdocument() function.
After Refresh
The delegate for the afterRefresh event.
Supported by
Page, Attachments Section, Canvas Section, Custom Section, Form Section, Grid Section, Image Strip Section, Notifications Section, TabView Section, Timeline Section, Webview Section
Notes
- Introduced in v3.4.
- This is called after a Refresh. It can be used, for example, to provide special display formatting specific to the context of the data being displayed.
After Row Change
The delegate for the afterRowChange event called when moving to a new row in a Canvas Section TreeGrid Advanced Control.
Supported by
Canvas Section TreeGrid Advanced Control
Notes
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
After Row/Col Change
The delegate for the Row/Col Change event (after cell selected).
Supported by
Notes
- From v6.3.1, previously (from v6.0) known as Row/Col Change delegate.
- The delegate is passed three arguments: nRow, nColumn, cValue.
- See also Before Row/Col Change.
After Save
The delegate for the Save event (after a save has completed).
Supported by
Notes
- From v9.9.9.
- See also Before Save
Before Data Create
The delegate for the beforeCreated event.
Supported by
Attachments Section, Canvas Section, Form Section, Grid Section, Grid Gadget
Notes
- The first event to be called when the Add button is clicked in the Page, Section or Gadget actionbar.
- See Adding a new record for more details.
Before Data Delete
The delegate for the beforeDelete event.
Supported by
Attachments Section, Canvas Section, Form Section, Grid Section, Grid Gadget
Notes
- The first event to be called when the Delete button is clicked in the Page, Section or Gadget actionbar.
- See Deleting a record for more details.
Before Data Update
The delegate for the beforeUpdate event.
Supported by
Attachments Section, Canvas Section, Form Section, Grid Section, Grid Gadget
Notes
- See Updating a record for more details.
- From v7.1, if the delegate returns false, the update is cancelled.
Before Edit
The delegate for the beforeEdit event.
Supported by
Attachments Section, Canvas Section, Custom Section, Form Section, Grid Section, Image Strip Section, Notifications Section, TabView Section, Timeline Section, Webview Section
Notes
- Introduced in v5.4.
- This is called when going into edit mode (after the Section or Page Edit button is clicked or the edit() or editmode() method called).
- It can be used, for example, to hide the Navigation Panel to provide additional space for editing the data.
- The Navigation Panel visibility can be controlled using the Lianja system object methods: Lianja.showNavigationPanel(), Lianja.showNavigationPanel() or Lianja.showNavigationPanel() or the hidenavigationpanel and shownavigationpanel actions with the Lianja.showDocument() method or showdocument() function.
Before preview
The delegate for the before preview event.
Supported by
Notes
- Introduced in v6.3.
- Run each time Preview live in browser is run.
- The delegate is called with the name of the App's database as a parameter.
- This is primarily used for continuous integration to deploy schema changes. See the COMPARE DATABASE command for more details.
Before Refresh
The delegate for the beforeRefresh event.
Supported by
Page, Attachments Section, Canvas Section, ChartView Section, Custom Section, Dashboard Section, DatalistView Section, Form Section, Grid Section, Image Strip Section, Notifications Section, TabView Section, Timeline Section, Webview Section
Notes
- Introduced in v6.2.
- For example this can be used in conjunction with the After Refresh delegate and Lianja system object methods for 'loading' feedback:
// before refresh Lianja.get("page.or.sectionid").hide() Lianja.showLoadingMessage("Your message...") // after refresh Lianja.get("page.or.sectionid").show() Lianja.hideLoadingMessage()
Before Row/Col Change
The delegate for the Row/Col Change event (before cell selected).
Supported by
Notes
- From v6.3.1.
- The delegate is passed three arguments: nRow, nColumn, cValue.
- See also After Row/Col Change.
Before Save
The delegate for the Save event (before a save is performed).
Supported by
Notes
- From v9.9.9.
- Returning false causes the changes to be discarded.
- See also After Save
Change
The delegate for the changed event.
Supported by
Page, Attachments Section, Canvas Section, Custom Section, Form Section, Grid Section, Image Strip Section, Notifications Section, TabView Section, Timeline Section, Webview Section, Form Section Field, Canvas Section Advanced Control, Checklistview Gadget, Grid Gadget
Notes
- Called when the Enter or Tab key is pressed in a Form Section Field or Canvas Section Advanced Control, when an item is checked in a Checklistview Gadget or when a row is updated and saved in a Grid Section or Grid Gadget.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
- Not to be confused with the Data Changed event delegate, which is called on Form Section Fields or Canvas Section Advanced Controls when navigating between records and after data modification operations (Form Section Fields only).
- If delegates are specified on multiple UI element levels, they are called in the following order:
- Formitem
- Section
- Page
Click
The delegate for the click event.
Supported by
Attachments Section, CatalogView Section, Image Strip Section, Org Chart Section, TreeView Section, Checklistview Gadget, Grid Section, Listview Gadget, Treeview Gadget, Canvas Section Advanced Controls
Notes
- In CatalogView Sections, the Click Custom Delegate is called when the 'Read more' attribute is set to True and the 'Read more' text is clicked. If a 'Read more delegate' is specified, this is called instead of the Click Custom Delegate. See CatalogView Options for more information on CatalogView Section specific options.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
- See Calendar Options for the Calendar Section 'Click delegate' called when a cell in the calendar is clicked.
Collapsed
The delegate for the collapsed event.
Supported by
All Sections (except Page Center)
Notes
- The Collapsed delegate is called when a collapsible Section is collapsed by clicking/tapping on its header.
- The Collapsed delegate is not called in Development View in the Lianja App Builder.
- When a Section is collapsed programmatically, the Collapsed delegate is not called. Sections can be collapsed using any of the following:
Lianja.get("pageid.sectionid").collapse(); Lianja.showDocument("page:pageid.sectionid?action=collapse"); Lianja.showDocument("section:sectionid?action=collapse");
- The Collapsable attribute determines whether a Section can be collapsed or whether it is always expanded. This is overridden in these cases:
- The last Section on a Page with the 'Stretch last section' attribute set to True cannot be collapsed (Desktop).
- The last Section on a Page cannot be collapsed (Web/Mobile).
- Sections with the 'Hide header' attribute set to True cannot be collapsed.
Connection State Changed
The delegate for the Connection State Changed event.
Supported by
Notes
- For web Apps running in mobile devices.
- See also the Lianja.getConnection() method.
Context Menu
The delegate for the Context Menu event.
Supported by
Form Section Fields, Canvas Section Numeric TextBox Advanced Control, Canvas Section TextBox Advanced Control
Notes
- Called when an item is selected from the control's context menu.
- The 'Context Menu' attribute (comma-separated string) defines a right-click context menu for the control.
- See Help Attributes: Context Menu for screenshots and an example.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
- Context menus are supported on the Desktop client only.
The delegate for the footer menu event.
Supported by
All Sections (except Page Center)
Notes
- See Section Footers for more details.
The delegate for the custom menu event.
Supported by
Notes
- In earlier versions, the delegate was listed in the Attributes as 'Custom menu'.
- Called when the options icon in the actionbar is clicked or, if options are specified in Custom options menu, when an option is selected.
- The attribute Show options icon is set to False by default. This must be checked (True) for the options menu icon to be displayed. Hide actionbar must be unchecked (False).
- If applicable, the selected menu option text is passed to the delegate as a parameter. See Custom options menu for details on defining the options menu.
- The example_webapp1 sample App demonstrates this delegate:
//////////////////////////////////////////////////////////////// // Event delegate for 'custommenu' event function Sales_custommenu(cText) { Lianja.writeOutput("Sales_custommenu:"+cText); };
The delegate for the custom settings menu event. The text of the menuitem selected is passed as a parameter.
Supported by
Notes
- Called when the settings icon in the actionbar is clicked or, if options are specified in Custom settings menu, when an option is selected.
- The attribute Show settings icon is set to False by default. This must be checked (True) for the settings menu icon to be displayed. Hide actionbar must be unchecked (False).
- If applicable, the selected menu option text is passed to the delegate as a parameter. See Custom settings menu for details on defining the options menu.
- The example_webapp1 sample App demonstrates this delegate (here no Custom settings menu is specified):
//////////////////////////////////////////////////////////////// // Event delegate for 'customsettings' event function Sales_customsettings(cMenuitemSelected) { Lianja.showDialogPanel("SETTINGS", "lib:/showdialog_map.rsp?address={customers.address}+{customers.city}+{customers.country}", 500); };
Custom search command
The delegate for the customsearch event.
Supported by
Page, All Sections (except Page Center)
Notes
- Called when the custom search icon in the Page or Section header is clicked.
- The attribute 'Hide custom search icon' is set to True by default. This must be unchecked (False) for the custom search icon to be displayed. See Custom Search for details.
- Custom Search is supported on the Desktop client only.
The delegate for the section menu event.
Supported by
All Sections (except Page Center)
Notes
- See Section Menus for more details.
Data Changed
The delegate for the dataChanged event.
Supported by
Form Section Fields, Canvas Section Advanced Controls
Notes
- Called when navigating between records.
- Also called after data modification operations (Form Section Fields only).
- See Event Delegate Sequences for more details.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
- See After Data Changed for the Section and Grid Gadget dataChanged event delegate.
- Not to be confused with the Change event delegate, which is called when the Enter or Tab key is pressed in a Form Section Field or Canvas Section Advanced Control or when an item is checked in a Checklistview Gadget.
Database changed
The delegate for the database changed event.
Supported by
Notes
- From v6.3.
- Called when the database is changed. The database can be changed using the Database Switcher the or Lianja.switchDatabase() method.
- The delegate is called with one argument: the name of the new database. You can then adjust captions etc. for the new tenant/customer if required. Database metadata can be attached to the database to specify customer specific captions.
Data Producer
The delegate for the dataProducer (used in Web Components).
Supported by
ArticleView Section, Calendar Section, CarouselView Section, CatalogView Section, Charts Section, ChartView Section, CommentsView Section, DatalistView Section, DocumentView Section, GalleryView Section, Org Chart Section, PanelView Section, Report Section, TreeView Section, WebView Section,
Notes
- From v6.1.
- This is called to replace {data} in Web Component parameters. Should return a string, e.g. "10,15,78". This can be used to produce the data string for ChartView Sections or custom Web Component data, i.e. specify data={data}.
Deactivate
The delegate for the deactivate event.
Supported by
App, Page, All Sections (except Page Center), Checklistview Gadget, Grid Gadget, Listview Gadget, Treeview Gadget, Form Section Fields, Canvas Section Advanced Controls
Notes
- The Deactivate delegate is called when leaving a Page.
- See Navigating between Pages for more details.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Default Action
The default action for this control.
Supported by
Canvas Section Advanced Controls.
Notes
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
- For CommandButtons this will be performed on a Click event. For other applicable controls, it will be performed on the Change event.
- Lianja/VFP scripting in Desktop Client only.
Destroy
The delegate for the destroy event.
Supported by
App, Page, All Sections (except Page Center).
Notes
- The Destroy delegate is called after the Unload delegate when closing an App.
- See Closing an App for more details.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Device Motion Changed
The delegate for the Device Motion Changed event.
Supported by
Notes
- For web Apps running in mobile devices.
- See also the Lianja.getCurrentAcceleration() method.
Dialog button delegate
The delegate for the dialogButtonClicked event.
Supported by
Page, Canvas Section, Form Section, Form Section Fields, Canvas Section TextBox Advanced Control
Notes
- If a dialogbutton on a Form Section Field or Canvas Section TextBox Advanced Control has no delegate specified, the Section delegate will be called. If the Section has no delegate specified, then the Page delegate will be called (desktop only).
- The 'Dialog button delegate' is listed below the 'Dialog button' attribute under the 'Data' attributes for Form Section Fields and Canvas Section TextBox Advanced Controls.
The delegate for the dialogButtonMenu event.
Supported by
Form Section Fields, Canvas Section TextBox Advanced Control
Notes
- The delegate is passed two arguments:
- id, the id/name of the UI control
- text: the text of the selected option from the Dialog button menu.
- Supported on all clients.
Double click
The delegate for the dblClick event.
Supported by
Attachments Section, CatalogView Section, Org Chart Section, TreeView Section, Treeview Gadget, Canvas Section Advanced Controls
Notes
- Called on an Attachments Section only if the Section is readonly.
- Called on a CatalogView Section when the Image is double-clicked.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Enabled When
The delegate for the enabledWhen event.
Supported by
Page, Attachments Section, Canvas Section, Custom Section, Form Section, Grid Section, Image Strip Section, Notifications Section, TabView Section, Timeline Section, Webview Section, Canvas Section Advanced Controls
Notes
- Pre v8.0 called on Desktop runtime only. From v8.0 supported on all clients.
- The Enabled When delegate is called when the UI Presentation Rules Readonly when attribute is checked when an App is opened.
- See Opening an App for more details.
- The Enabled When delegate is also called when the UI Presentation Rules Readonly when attribute is checked when moving between Pages.
- See Navigating between Pages for more details.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
- The Enabled When delegate is called when the parent data is changed by navigating records if the Section Apply rules on parent change attribute is checked.
- The Enabled When delegate is called when data is changed interactively and when navigating records if the Apply rules on change attribute is checked.
Expanded
The delegate for the expanded event.
Supported by
All Sections (except Page Center).
Notes
- The Expanded delegate is called when a collapsed collapsible Section is expanded by clicking/tapping on its header.
- The Expanded delegate is not called in Development View in the Lianja App Builder.
- When a Section is expanded programmatically, the Expanded delegate is not called. Sections can be expanded using any of the following:
Lianja.get("pageid.sectionid").expand() Lianja.showDocument("page:pageid.sectionid?action=expand") Lianja.showDocument("section:sectionid?action=expand")
- The Collapsable attribute determines whether a Section can be collapsed or whether it is always expanded. This is overridden in these cases:
- The last Section on a Page with the 'Stretch last section' attribute set to True cannot be collapsed (Desktop).
- The last Section on a Page cannot be collapsed (Web/Mobile).
- Sections with the 'Hide header' attribute set to True cannot be collapsed.
File System Watcher
The delegate procedure for watching for changes to directories and/or files.
Supported by
Notes
- Called with a single argument containing the name of the watched file or directory that has changed.
- To watch a file or directory, use the Lianja WatchFile method.
- To stop watching a file or directory, use the Lianja UnwatchFile method.
- Desktop only.
- From v4.1.
Gestures
The catch all delegate for the gestures event.
Supported by
Page, Attachments Section, Canvas Section, Form Section, Grid Section, Notifications Section, TabView Section, Timeline Section
Notes
- Called with two arguments to indicate the gesture, e.g. "swipe", "left".
- The 'Gestures enabled' attribute must be checked (True).
Got Focus
The delegate for the gotFocus event.
Supported by
Form Section Fields, Canvas Section Advanced Controls
Notes
- Called on Form Section Fields in the Web/Mobile client only.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
- See Event Delegate Sequences for more information.
Hotkey
The delegate for the hotkey event, e.g. F1-F12, Ins, Backspace, Delete, Up, Down, Left, Right, PgUp, PgDn, Home, End, ctrl+F1, alt+F1, shift+F1 (and other ctrl/alt/shift + combinations).
Supported by
App, Page, Form Section Fields, Canvas Section Advanced Controls, All Sections (except Page Center)
Notes
- The key is passed as a parameter, e.g. "F1" or "ctrl+F12".
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Inactive
The delegate for the inactive event.
Supported by
Notes
- The 'Inactive interval' attribute defines the interval in seconds that the inactive delegate will be called at runtime.
- Called at runtime only.
Init
The delegate for the init event.
Supported by
App, Page, All Sections (except Page Center), Checklistview Gadget, Grid Gadget, Listview Gadget, Treeview Gadget, Form Section Fields, Canvas Section Advanced Controls.
Notes
- Init is the first of the four key events to be called when an App is opened:
- Init
- Load
- Ready
- Activate
- See Opening an App for more details.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Init Form Defaults
The delegate for the initFormDefaults event called when adding a new record.
Supported by
Attachments Section, Canvas Section, ChartView Section, Custom Section, Dashboard Section, DatalistView Section, Form Section, Grid Section, Imagestrip Section, Notifications Section, Tabview Section, Timeline Section, Webview Section
Notes
- This can be used to set up any custom defaults.
Init Form
The delegate for the initForm event called when creating a component form.
Supported by
Notes
- You can open a database and the database tables required by the component form in this delegate.
- Activating a form will automatically PUSH DATASESSION / POP DATASESSION, so there is no need to do this.
- See Working with Visual Components
- Note that when initForm is called *thisform* points to the form object and thisform.controls(1) points to the main container in the form.
- From v7.2.
Instant Search
The delegate for the Instant search event.
Supported by
Page.
Notes
- The Instant Search delegate is called each time a printable character is typed in the Instant Search Box. The current Instant Search Box value is passed to the delegate as a parameter.
- The 'Minimum search text length' Page attribute can be used to delay the search and the calling of the Instant Search custom delegate until the specified number of characters has been entered.
- See Instant Search for more on Instant Search.
- From v5.5.1 the Instant Search delegate is also called when a Page Left Sidebar Favorites, Recently Viewed or Recently Modified item is clicked. This enables these items to be used with Virtual Tables.
Instant Selection
The delegate for the Instant selection event. From v5.5.1.
Supported by
Page.
Notes
- The Instant Selection delegate is called when an Instant Selection is clicked. The selection's filter condition string is passed to the delegate as a parameter.
- This enables Instant Selections to be used with Virtual Tables.
- The 'is like' and 'is not like' comparisons are supported in Instant Selections from v5.5.1.
- See Getting Started 2 for more on Instant Selections.
Interactive Change
The delegate for the interactiveChange event. This is called after each key is pressed.
Supported by
Form Section Fields, Canvas Section Advanced Controls, Grid Sections
Notes
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
- Supported in Grid Sections from v6.0, where it is called after cell editing is completed.
- For Grid Sections, the delegate is passed three arguments: nRow, nColumn, cValue.
Link Click
The delegate for the linkClick event.
Supported by
Grid Section, Form Section Fields, Canvas Section Hyperlink Advanced Control
Notes
- Called on a Grid Section when any of its columns displayed as a button - 'Button' attribute checked (True) - or as a hyperlink - 'Hyperlink' attribute checked (True) - is clicked.
- Called on a Form Section Field its 'Hyperlink' attribute is checked (True) and it is clicked.
- This is called with two arguments: functionname(controlsource,text).
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Load
The delegate for the load event.
Supported by
App, Page, All Sections (except Page Center), Checklistview Gadget, Grid Gadget, Listview Gadget, Treeview Gadget, Form Section Fields, Canvas Section Advanced Controls
Notes
- Load is the second of the four key events to be called when an App is opened:
- Init
- Load
- Ready
- Activate
- See Opening an App for more details.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Lost Focus
The delegate for the lostFocus event.
Supported by
Form Section Fields, Canvas Section Advanced Controls
Notes
- Called on Form Section Fields in the Web/Mobile client only.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
- See Event Delegate Sequences for more information.
Middle Click
The delegate for the middleClick event.
Supported by
Canvas Section Advanced Controls
Notes
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Mouse Down
The delegate for the mouseDown event.
Supported by
Canvas Section Advanced Controls
Notes
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Mouse Enter
The delegate for the mouseEnter event.
Supported by
Canvas Section Advanced Controls
Notes
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Mouse Leave
The delegate for the mouseLeave event.
Supported by
Canvas Section Advanced Controls
Notes
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Mouse Move
The delegate for the mouseMove event.
Supported by
Canvas Section Advanced Controls
Notes
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Mouse Up
The delegate for the mouseUp event.
Supported by
Canvas Section Advanced Controls
Notes
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Orientation Changed
The delegate for the Orientation Changed event.
Supported by
Notes
- For web Apps running in mobile devices.
- See also the Lianja.getOrientation() method.
Pan gesture
The delegate for the gesturePan event.
Supported by
Page, Attachments Section, Canvas Section, Form Section, Grid Section, Notifications Section, TabView Section, Timeline Section
Notes
- The 'Gestures enabled' attribute must be checked (True).
Parent data changed
The delegate for the parentDataChanged event.
Supported by
all Sections (except Page Center)
Notes
- For Sections with a related parent Section, called when the data in the parent section changes.
- See Event Delegate Sequences.
Pinch gesture
The delegate for the gesturePinch event.
Supported by
Page, Attachments Section, Canvas Section, Form Section, Grid Section, Notifications Section, TabView Section, Timeline Section
Notes
- The 'Gestures enabled' attribute must be checked (True).
The delegate for the print event.
Supported by
Page, All Sections (except Page Center)
Notes
- If the Print delegate exists, it overrides the default print action.
- We recommend using a Webview object in conjunction with a Lianja/VFP Server Page (.rsp) file to generate the output for printing.
- See the information about the report.rsp Lianja/VFP Server Page included in the Lianja App Builder distribution and how it could be used as a template for your own printouts.
- See the Webview print() and printpreview() methods for full details on the available parameters.
- JavaScript example:
wv = createObject("webview"); wv.url = "library:/report.rsp"; wv.print(); // or wv.printpreview();
Ready
The delegate for the ready event.
Supported by
App, Page, All Sections (except Page Center), Checklistview Gadget, Grid Gadget, Listview Gadget, Treeview Gadget, Form Section Fields, Canvas Section Advanced Controls
Notes
- Ready is the third of the four key events to be called when an App is loaded:
- Init
- Load
- Ready
- Activate
- See Opening an App for more details.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Refresh
The delegate for the refresh event.
Supported by
Attachments Section, Canvas Section, Custom Section, Form Section, Grid Section, Image Strip Section, Notifications Section, TabView Section, Timeline Section, Webview Section, Checklistview Gadget, Grid Gadget
Notes
Resize
The delegate for the resize event.
Supported by
Canvas Section Advanced Controls
Notes
- Called when the Canvas Section parent container is resized.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each EditBox, Image, Label and Rich Text Editor Canvas Section Advanced Controls.
Resized
The delegate for the resized event.
Supported by
Canvas Section and Custom Section
Notes
- Called when the Canvas Section or Custom Section is resized.
Right Click
The delegate for the rightclick event.
Supported by
Attachments Section, Form Section, Grid Section, Tabview Section, Timeline Section
Notes
- Called when an item is selected in a Context Menu.
Row/Col Change
The delegate for the Row/Col Change event (after cell selected, before editing).
Supported by
Notes
- From v6.0.
- The delegate is passed three arguments: nRow, nColumn, cValue.
- This has been replaced in v6.3.1 by the Before Row/Col Change and After Row/Col Change delegates.
Selection Changed
The delegate for the selectionChanged event (for multi row selection).
Supported by
Notes
- This is called when a row is selected or deselected on Grid Sections which have the 'MultiSelect rows' attribute set to True (default is False).
- If the Grid Section's 'MultiSelect rows expression' attribute is specified, then this is evaluated and passed to the Selection Changed custom delegate as a parameter.
Sort
The delegate for the column sort event fired when the column header is clicked.
Supported by
Attachments Section, Grid Section and Grid Gadget
Notes
- Prior to v6.0 the Sort delegate was called on Desktop (at runtime) only. From v6.0, the Sort delegate is also supported in the web client.
- The Sort delegate is called with two arguments: nColumn, nDirection. Starting from 1, nColumn is the number of the column clicked. The nDirection argument indicates whether the requested sort is ascending (1) or descending (-1).
- The Attachments Section or Grid Section must have the Sortable attribute set to True for the Sort delegate to be called.
- If the Sort delegate is defined, the automatic sorting of sortable Attachments and Grid Sections is disabled (Desktop only).
- See Sortable Grid Sections (Video) for more on automatic sorting.
State Changed
The delegate for the Statechanged event.
Supported by
App, Page, All Sections (except Page Center), Checklistview Gadget, Grid Gadget, Listview Gadget, Treeview Gadget, Form Section Fields, Canvas Section Advanced Controls
Notes
- Introduced in Lianja v3.2.
- Called whenever a UI State is changed.
- The State Changed delegate is called with one argument, the name of the state. When a state is reset, the name of the state is passed with a '-' prefix, e.g. '-state1'.
- State changes do not operate in development view.
- See UI States for information on UI States.
- See Using the showdocument() function and Lianja.showDocument() method for information on the changestate and resetstate actions.
Swipe down gesture
The delegate for the gestureSwipeDown event.
Supported by
Page, Attachments Section, Canvas Section, Form Section, Grid Section, Notifications Section, TabView Section, Timeline Section
Notes
- The 'Gestures enabled' attribute must be checked (True).
Swipe left gesture
The delegate for the gestureSwipeLeft event.
Supported by
Page, Attachments Section, Canvas Section, Form Section, Grid Section, Notifications Section, TabView Section, Timeline Section
Notes
- The 'Gestures enabled' attribute must be checked (True).
Swipe right gesture
The delegate for the gestureSwipeRight event.
Supported by
Page, Attachments Section, Canvas Section, Form Section, Grid Section, Notifications Section, TabView Section, Timeline Section
Notes
- The 'Gestures enabled' attribute must be checked (True).
Swipe up gesture
The delegate for the gestureSwipeUp event.
Supported by
Page, Attachments Section, Canvas Section, Form Section, Grid Section, Notifications Section, TabView Section, Timeline Section
Notes
- The 'Gestures enabled' attribute must be checked (True).
Tap gesture
The delegate for the gestureTap event.
Supported by
Page, Attachments Section, Canvas Section, Form Section, Grid Section, Notifications Section, TabView Section, Timeline Section
Notes
- The 'Gestures enabled' attribute must be checked (True).
Tap and hold gesture
The delegate for the gestureTapAndHold event.
Supported by
Page, Attachments Section, Canvas Section, Form Section, Grid Section, Notifications Section, TabView Section, Timeline Section
Notes
- The 'Gestures enabled' attribute must be checked (True).
Text Translator
The delegate procedure for translating text messages.
Supported by
Notes
- See Text Translator for more details.
Timer
The delegate for the timer event.
Supported by
Page, All Sections (except Page Center), Grid Gadget, Form Section Fields, Canvas Section Advanced Controls
Notes
- The 'Timer interval' attribute defines the timer interval in seconds that the timer event will be called at runtime.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Unload
The delegate for the unload event.
Supported by
App, Page, All Sections (except Page Center).
Notes
- The Unload delegate is called before the Destroy delegate when closing an App.
- See Closing an App for more details.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
Valid When
The delegate for the validWhen event.
Supported by
Page, Attachments Section, Canvas Section, Form Section, Grid Section
Notes
- Called prior to the beforeUpdate event.
- See Event Delegate Sequences: Updating a record.
Visible When
The delegate for the visibleWhen event.
Supported by
Page, Attachments Section, Canvas Section, Custom Section, Form Section, Grid Section, Image Strip Section, Notifications Section, TabView Section, Timeline Section, Webview Section, Canvas Section Advanced Controls
Notes
- Pre v8.0 called on Desktop runtime only. From v8.0 supported on all clients.
- The Visible When delegate is called when the UI Presentation Rules Visible when attribute is checked when an App is opened.
- See Opening an App for more details.
- The Visible When delegate is also called when the UI Presentation Rules Visible when attribute is checked when moving between Pages.
- See Navigating between Pages for more details.
- See Advanced Canvas Control Custom Delegates for more on the custom delegates supported by each Canvas Section Advanced Control.
- The Visible When delegate is called when the parent data is changed by navigating records if the Section Apply rules on parent change attribute is checked.
- The Visible When delegate is called when data is changed interactively and when navigating records if the Apply rules on change attribute is checked.
Event Sequences
Loading an App
- Init
- Load
- DataChanged
- ParentDataChanged
- Refresh
- VisibleWhen (Runtime only)
- EnabledWhen (Runtime only)
- Ready
- Resized (Canvas and Custom Sections)
- Activate
For more details see Event Delegate Sequences: Opening an App.
Closing an App
- Unload
- Destroy
For more details see Event Delegate Sequences: Closing an App.
- See Event Delegate Sequences: Navigating between Pages.
- See Event Delegate Sequences: Navigating Form Section.
- See Event Delegate Sequences: Navigating Grid Section.
Data Operations
- See Event Delegate Sequences: Adding a new record.
- See Event Delegate Sequences: Updating a record.
- See Event Delegate Sequences: Deleting a record.
Other Delegates
App
Dynamic tile producer
The dynamic tile producer used to update the dynamic tile in the App Center.
- This can be a procedure or a Lianja/VFP Server Page (.rsp) or JavaScript Server Page (.jssp).
- The 'Dynamic contents' App Setting must be checked (True).
- Apps with dynamic contents do not open in the Lianja App Center.
- The 'Dynamic tile timer interval' setting determines the timer interval in seconds to update the dynamic tile in the App Center.
- The Lianja App Builder distribution includes example 'Demo Dynamic Tiles' Apps: example_dynamictile1, example_dynamictile2 and example_dynamictile3.
- Supported on the Desktop client only.
Session data changed
The delegate for the Session Data Changed event
Page
Custom Actions
Custom Actions allow the developer to override the default actions when a button is clicked in the Page actionbar or its corresponding method is called programatically.
If the custom action delegate returns true the standard action is not executed. If it returns false the standard action is executed.
Add action
Delegate called when the 'Add New Record' button is clicked in the Page actionbar.
Cancel action
Delegate called when the 'Undo Changes' button is clicked in the Page actionbar.
Delete action
Delegate called when the 'Delete Record' button is clicked in the Page actionbar.
Edit action
Delegate called when the 'Edit Record' button is clicked in the Page actionbar.
First action
Delegate called when the 'First Record' button is clicked in the Page actionbar.
Last action
Delegate called when the 'Last Record' button is clicked in the Page actionbar.
Next action
Delegate called when the 'Next Record' button is clicked in the Page actionbar.
Previous action
Delegate called when the 'Previous Record' button is clicked in the Page actionbar.
Refresh action
Delegate called when the 'Refresh Page' button is clicked in the Page actionbar.
Save action
Delegate called when the 'Save Changes' button is clicked in the Page actionbar.
See Understanding Lianja UI Navigation for more on navigation techniques.
Add delegate
The navtreeAdd delegate called when the 'Add' icon is clicked.
- The 'Add' icon is displayed when the 'Show ActionBar' Page attribute is checked (True).
- An 'inline' delegate can be used, e.g. $("section:yoursectionid?action=add")
- Supported on the Desktop client only.
Delete delegate
The navtreeDelete delegate called when the 'Delete' icon is clicked.
- The 'Delete' icon is displayed when the 'Show ActionBar' Page attribute is checked (True).
- An 'inline' delegate can be used, e.g. $("section:yoursectionid?action=delete")
- Supported on the Desktop client only.
Selection delegate
The navtreeSelection delegate called when a row is clicked.
- An 'inline' delegate can be used, e.g. $("section:yoursectionid?action=search&text={}"). Notice how {} is used to substitute the value of the item selected.
- Supported on the Desktop client only.
Calendar Section
Click delegate
Delegate to call when a calendar event is clicked.
Custom delegate library
Custom library containing the day and event dynamic color delegates.
Dynamic day backcolor
Delegate to return the background colors and dates.
- The colors should be returned as a comma separated list.
- The delegate is called with one parameter: 'dates' or 'colors'. The currently selected cursor contains the selected records.
- See Calendar Section Options: Dynamic day backcolor.
Dynamic event backcolor
Delegate to return the background color of the event for the specified event type, which is passed as a parameter.
Dynamic event forecolor
Delegate to return the foreground color of the event for the specified event type, which is passed as a parameter.
CatalogView Section
CatalogView Section Attributes
Caption delegate
The inline delegate to invoke when the caption is clicked.
Custom library
Custom library containing the Tile producer delegate.
Read more delegate
The inline delegate to invoke when the 'Read more' link is clicked.
- Alternatively, the 'Click' delegate can be used.
- See Details Attributes
Tile producer
Delegate to call to render a custom tile.
- This should just output the HTML.
- See Extension Attributes
Charts Section
Delegate
An optional delegate to be called when segments of the chart are selected.
- Supported by:
- Funnel Chart Section
- Gantt Chart Section
- Horizontal Bar Chart
- Pie Chart
- Vertical Bar Chart
- The tooltip of the selected segment (as defined in the 'Tooltips' attribute) is passed to the custom delegate.
- By default, if no delegate is specified, the tooltip of the selected segment will be used as a search key on the Page, equivalent to showdocument("page:current-pageid?action=search&text=tooltip")
- Supported on the Desktop client only.
GalleryView Section
GalleryView Section Attributes
Custom library
Custom library containing the Tile producer and Content producer delegates.
Content producer
Delegate to call to render the content.
- This should just output the HTML.
- See GalleryView Section: Content producer
Tile producer
Delegate to call to render a custom tile.
- This should just output the HTML.
- See GalleryView Section: Tile producer
Org Chart Section
Custom delegate library
Custom library containing the dynamic color delegates.
Search Panel
Supported by all Sections (except Page Center)
Custom search panel
The delegate used to create the custom search panel.
Fields and Grid Columns
Form Section Fields, Grid Section Columns, Canvas Section Advanced Controls
Validation
The Validation expression for editable fields, columns and controls can be a call to a user defined function.
- The Validation expression is checked on exiting a modified field, control or cell.
- See Updating a record for more details.
Inline Delegates
Inline Delegates - a single command - must be used for the Default Action, but they can also be used for other delegates in place of a function or procedure call.
Desktop
! Prefix
Prefix the command with a !:
Lianja/VFP
!? "Hello World"
JavaScript
!print("Hello World")
PHP
!echo "Hello World"
Python
!print "Hello World"
Lianja Methods
Call supported Lianja methods with no prefix:
All
Lianja.writeLog("Hello World")
PHP
Lianja::writeLog("Hello World")
? Prefix
Prefix Lianja.showdocument() actions with a ?:
?page:page2
is the equivalent of:
Lianja.showDocument("page:page2")
$ Prefix
Or, prefix Lianja.showdocument() actions (including the parentheses and quotes) with a $:
$("page:page2")
is the equivalent of:
Lianja.showDocument("page:page2")
|| Chaining
As with the full Lianja.showDocument() method or the SHOWDOCUMENT() function, multiple actions can be chained by separating them with ||, e.g.
$("section:section3?action=hide||section:section2?action=hide")
Web/Mobile Apps
Inline delegates must be written in JavaScript.
Commands and supported Lianja methods can be written without any prefix:
window.alert("Hello World") Lianja.writeLog("Hello World") Lianja.getElementByID("page1.section1").hide()
? Prefix
Prefix Lianja.showdocument() actions with a ?:
?page:page2
is the equivalent of:
Lianja.showDocument("page:page2")
$ Prefix
Or, prefix Lianja.showdocument() actions (including the parentheses and quotes) with a $:
$("page:page2")
is the equivalent of:
Lianja.showDocument("page:page2")
|| Chaining
As with the full Lianja.showDocument() method or the SHOWDOCUMENT() function, multiple actions can be chained by separating them with ||, e.g.
$("section:section3?action=show||section:section2?action=show")