Difference between revisions of "Custom Delegates"

From Lianjapedia
Jump to: navigation, search
Line 396: Line 396:
 
* 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 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.
 
* 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.
  
 
==Link Click==
 
==Link Click==

Revision as of 10:47, 28 April 2016

Contents

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 and Web/Mobile Apps.
PHP Desktop Apps only.

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.

Custom 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:
  1. Init
  2. Load
  3. Ready
  4. Activate

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

After Data Create

The delegate for the afterCreated event.

Supported by

Attachments Section, Canvas Section, Form Section, Grid Section, Grid Gadget

Notes

After Data Delete

The delegate for the afterDelete event.

Supported by

Attachments Section, Canvas Section, Form Section, Grid Section, Grid Gadget

Notes

After Data Update

The delegate for the afterUpdate event.

Supported by

Attachments Section, Canvas Section, Form Section, Grid Section, Grid Gadget

Notes

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

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

Change

The delegate for the change event.

Supported by

Form Section Field, Canvas Section Advanced Control, Checklistview Gadget

Notes

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

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.

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

Custom footer menu

The delegate for the footer menu event.

Supported by

All Sections (except Page Center)

Notes

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.

Custom section menu

The delegate for the section menu event.

Supported by

All Sections (except Page Center)

Notes

Data Changed

The delegate for the dataChanged event.

Supported by

Form Section Fields, Canvas Section Advanced Controls

Notes

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

Default Action

The default action for this control.

Supported by

Canvas Section Advanced Controls.

Notes

Destroy

The delegate for the destroy event.

Supported by

App, Page, All Sections (except Page Center).

Notes

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

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

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

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.

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

Hotkey

The delegate for the hotkey event, e.g. F1 - F10, Ctrl+F1.

Supported by

Form Section Fields, Canvas Section Advanced Controls

Notes

Inactive

The delegate for the inactive event.

Supported by

App

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:
  1. Init
  2. Load
  3. Ready
  4. Activate

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

Notes

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.

Link Click

The delegate for the linkClick event.

Supported by

Grid Section, Form Section Fields, Canvas Section Hyperlink Advanced Control

Notes

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:
  1. Init
  2. Load
  3. Ready
  4. Activate

Lost Focus

The delegate for the lostFocus event.

Supported by

Form Section Fields, Canvas Section Advanced Controls

Notes

Middle Click

The delegate for the middleClick event.

Supported by

Canvas Section Advanced Controls

Notes

Mouse Down

The delegate for the mouseDown event.

Supported by

Canvas Section Advanced Controls

Notes

Mouse Enter

The delegate for the mouseEnter event.

Supported by

Canvas Section Advanced Controls

Notes

Mouse Leave

The delegate for the mouseLeave event.

Supported by

Canvas Section Advanced Controls

Notes

Mouse Move

The delegate for the mouseMove event.

Supported by

Canvas Section Advanced Controls

Notes

Mouse Up

The delegate for the mouseUp event.

Supported by

Canvas Section Advanced Controls

Notes

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).

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:
  1. Init
  2. Load
  3. Ready
  4. Activate

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

Resized

The delegate for the resized event.

Supported by

Canvas Section and Custom Section

Notes

Selection Changed

The delegate for the selectionChanged event (for multi row selection).

Supported by

Grid Section

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

  • The Sort delegate is called on Desktop runtime only.
  • 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.

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).

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

Unload

The delegate for the unload event.

Supported by

App, Page, All Sections (except Page Center).

Notes

Valid When

The delegate for the validWhen event.

Supported by

Page, Attachments Section, Canvas Section, Form Section, Grid Section

Notes

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

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.

Navigating

Data Operations

Other Delegates

App

App Settings

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

Page Attributes

Custom Actions

Custom Actions allow the developer to override the default actions when a button is clicked in the Page actionbar.

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.

Navigation Panel

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

Calendar Section Attributes

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.

Tile producer

Delegate to call to render a custom tile.

Charts Section

Charts Section Attributes

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.

Tile producer

Delegate to call to render a custom tile.

Org Chart Section

Org Chart Section Attributes

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")