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.





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.





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


Properties


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


addNavigationListener(listener)

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


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

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

Example

scopes.svyNavigation.removeNavigationListener(onOpen);

Last updated