API svyNavigation

Classes

NavigationItem

Functions

addNavigationListener(listener)

createNavigationItem([formName], [text], [tooltipText])NavigationItem

Creates a NavigationItem object to the given formName

getCurrentItem()NavigationItemgetVersion()String

Gets the version of this module

open(itemOrID, [dataToShow], [dataSelectionType])Boolean

Opens the navigation item. If the item already exists in the stack, then all items after the specified item are closed beforeClose event will be fired allowing a chance to react or cancel afterOpen will fire allowing UIs to update

removeNavigationListener(listener)Boolean


Example

function onShow() {
  // get the current navigation item
   var item = scopes.svyNavigation.getCurrentItem();
   var customData = item.getCustomData();
   if (customData && customData.filter) {
      var filter = customData.filter;
      foundset.addFoundSetFilterParam(filter.dataprovider, filter.operator, filter.values);
      foundset.loadRecords();
   }
}

Gets the name of the form associated with this navigation item.





Param
Type

customData

*

Example

var item = new scopes.svyNavigation.NavigationItem("ordersTableView");
item.setCustomData({ filter: { dataprovider: "orderdate", operator: "between", values: [startDate, endDate] } });
scopes.svyNavigation.open(item);

Sets the name of the form associated with this navigation item.

Param
Type

formName

String


Param
Type

text

String


Param
Type

tooltipText

String



new NavigationItem([formName], [text], [tooltipText])

Param
Type

[formName]

String

[text]

String

[tooltipText]

String


Properties

Name
Default
Description

BEFORE_CLOSE

before-close

register for navigation event to listen for this event (@see addNavigationListener) beforeClose event will be fired before navigating allowing a chance to react or cancel

AFTER_OPEN

after-open

register for navigation event to listen for this event (@see addNavigationListener) afterOpen event will be fired when a navigation item has been opened; react to the after_open event to implement your navigation


Enumeration for the data selection type specified in the open function. The chosen selection type is passed to the open function [open](@link open) [afterOpen](@link afterOpen) and needs to be implemented accordingly. The Default value is LOAD_RECORDS

See: open(itemOrId, dataToShow, dataSelectionType) Properties

Name
Default
Description

LOAD_RECORDS

load-records

This is the DEFAULT selection type. Will run foundset.loadRecords(dataToShow) on the form to be shown. Load records into the form's foundset. If you load a relation into this foundset, then this foundset will not be a related foundset, it will not automatically update its state of records are updated or added that belong to that relation. It will only be a snapshot of that related foundsets state. Foundset filter params are copied over from the source foundset and are merged with the existing filters on this foundset.

SET_FOUNDSET

set-foundset

Can be used only when the dataToShow is of type JSFoundSet. Will run controller.loadRecords(dataToShow) for the target form. Replace the default form's foundset with setting the (related) foundset into the form. The form will no longer share the default foundset with forms of the same datasource, use loadAllRecords to restore the default foundset. This will really update the foundset instance itself of the form, so now existing foundset is altered just the new foundset is shown. When the form uses a seperate foundset, foundset filter params are copied over from the source foundset and are merged with the existing filters.

SELECT_RECORD

select-record

Can be used only when the dataToShow is a JSRecord. Selects the record with the given pk in the foundset even if the record is not loaded in foundset yet. Warning: can be very expensive, as the entire foundset may needs to be loaded. Returns false if the record cannot be found in the entire foundset.

FORCE_SELECT_RECORD

force-select-record

Can be used only when the dataToShow is a JSRecord. Selects the record with the given pk in the foundset even if the record is not loaded in foundset yet. Warning: can be very expensive, as the entire foundset may needs to be loaded. Returns false if the record cannot be found in the entire foundset. If the record is not present in the foundset will force the selection by loading all records into the foundset. If there are active foundset or table filters these won't be removed, they will still apply.


addNavigationListener(listener)

Param
Type

listener

function

Example

// register for navigation event
scopes.svyNavigation.addNavigationListener(onOpen);

function onOpen(event) {
	var type = event.getEventType();
	if (type == scopes.svyNavigation.NAVIGATION_EVENT.AFTER_OPEN) {
		var item = event.getNavigationItem();
		var formName = item.getFormName();
		var dataToShow = event.getDataToShow();
		var dataSelectionType = event.getDataSelectionType();
		
		// get the form instance
		var form = forms[formName];
		
		switch (dataSelectionType) {
		case scopes.svyNavigation.NAVIGATION_SELECTION_TYPE.LOAD_RECORDS:
		// load the given data into the foundset form
		if (dataToShow instanceof JSFoundSet) {
			// load the passed foundset into the form's foundset
			form.foundset.loadRecords(dataToShow);
		} else if (dataToShow instanceof QBSelect) {
			// load the QBSelect into the form's foundset
			form.foundset.loadRecords(dataToShow);
		} else if (dataToShow instanceof JSRecord) {
			// load the record into the form's foundset
			scopes.svyDataUtils.loadRecords(form.foundset, dataToShow.getPKs());
		}
		break;
		case scopes.svyNavigation.NAVIGATION_SELECTION_TYPE.SET_FOUNDSET:
			form.controller.loadRecords(dataToShow);
			break;
		default:
			break;
		}
		
		// show the form
		application.showForm(form);
	} else if (event.getEventType() == scopes.svyNavigation.NAVIGATION_EVENT.BEFORE_CLOSE) {
     // cancel navigation if there are pending edits to be saved
     if (databaseManager.getEditedRecords().length) {
         return false;   // or ask in a dialog
     }
 }
	return true;
}

createNavigationItem([formName], [text], [tooltipText]) ⇒ NavigationItem

Creates a NavigationItem object to the given formName

Param
Type

[formName]

String

[text]

String

[tooltipText]

String


getCurrentItem() ⇒ NavigationItem


getVersion() ⇒ String

Gets the version of this module

Returns: String - the version of the module using the format Major.Minor.Revision


open(itemOrID, [dataToShow], [dataSelectionType]) ⇒ Boolean

Opens the navigation item. If the item already exists in the stack, then all items after the specified item are closed beforeClose event will be fired allowing a chance to react or cancel afterOpen will fire allowing UIs to update

Param
Type
Description

itemOrID

[dataToShow]

JSRecord | JSFoundSet | QBSelect

The data to show for the given navigation item. The data is passed to the afterOpen event

[dataSelectionType]

String

Determine the type of selection in the target navigation item with the given dataToShow NAVIGATION_SELECTION_TYPE enumeration options. The chosen selection type is passed to the afterOpen and needs to be implemented accordingly. Default NAVIGATION_SELECTION_TYPE.LOAD_RECORDS

Example

//open a form
var item = new scopes.svyNavigation.NavigationItem(formName);
scopes.svyNavigation.open(item);

//open an item and pass data selection
var item = new scopes.svyNavigation.NavigationItem(formName);
scopes.svyNavigation.open(item,foundset.getSelectedRecord(),scopes.svyNavigation.NAVIGATION_SELECTION_TYPE.LOAD_RECORDS);

// open a form and pass custom data
var item = new scopes.svyNavigation.NavigationItem("ordersTableView");
item.setCustomData({ filter: { dataprovider: "orderdate", operator: "between", values: [startDate, endDate] } });
scopes.svyNavigation.open(item);

removeNavigationListener(listener) ⇒ Boolean

Param
Type

listener

function

Example

scopes.svyNavigation.removeNavigationListener(onOpen);

Last updated