Class sap.m.NavContainerModule: sap/m/NavContainer
The NavContainer control handles hierarchic navigation between Pages or other fullscreen controls.
All children of this control will receive navigation events like beforeShow, they are documented in the pseudo interface sap.m.NavContainerChild
sClassName
and enriches it with the information contained in oClassInfo
.fnFunction
to the afterNavigate
event of this sap.m.NavContainer
.fnFunction
to the navigate
event of this sap.m.NavContainer
.fnFunction
from the afterNavigate
event of this sap.m.NavContainer
.fnFunction
from the navigate
event of this sap.m.NavContainer
.initialPage
, or null
.defaultTransitionName
. Accepts an object literal mSettings
that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject for a general description of the syntax of the settings object.
The supported settings are:
- Properties
- autoFocus : boolean (default: true)
- height : sap.ui.core.CSSSize (default: 100%)
- width : sap.ui.core.CSSSize (default: 100%)
- visible : boolean (default: true)
- defaultTransitionName : string (default: slide)
- Aggregations
- pages : sap.ui.core.Control[] (default)
- Events
- navigate : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
- afterNavigate : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
In addition, all settings applicable to the base type sap.ui.core.Control can be used as well.
{string} | sId? | id for the new control, generated automatically if no id is given |
{object} | mSettings? | initial settings for the new control |
{sap.ui.base.Event} | oControlEvent | |
{sap.ui.base.EventProvider} | oControlEvent.getSource | |
{object} | oControlEvent.getParameters | |
{sap.ui.core.Control} | oControlEvent.getParameters.from | The page which had been shown before navigation. |
{string} | oControlEvent.getParameters.fromId | The ID of the page which had been shown before navigation. |
{sap.ui.core.Control} | oControlEvent.getParameters.to | The page which is now shown after navigation. |
{string} | oControlEvent.getParameters.toId | The ID of the page which is now shown after navigation. |
{boolean} | oControlEvent.getParameters.firstTime | Whether the "to" page (more precisely: a control with the ID of the page which has been navigated to) had not been shown/navigated to before. |
{boolean} | oControlEvent.getParameters.isTo | Whether was a forward navigation, triggered by "to()". |
{boolean} | oControlEvent.getParameters.isBack | Whether this was a back navigation, triggered by "back()". |
{boolean} | oControlEvent.getParameters.isBackToTop | Whether this was a navigation to the root page, triggered by "backToTop()". |
{boolean} | oControlEvent.getParameters.isBackToPage | Whether this was a navigation to a specific page, triggered by "backToPage()". |
{string} | oControlEvent.getParameters.direction | How the navigation was triggered, possible values are "to", "back", "backToPage", and "backToTop". |
- Since:
- 1.7.1
{sap.ui.base.Event} | oControlEvent | |
{sap.ui.base.EventProvider} | oControlEvent.getSource | |
{object} | oControlEvent.getParameters | |
{sap.ui.core.Control} | oControlEvent.getParameters.from | The page which was shown before the current navigation. |
{string} | oControlEvent.getParameters.fromId | The ID of the page which was shown before the current navigation. |
{sap.ui.core.Control} | oControlEvent.getParameters.to | The page which will be shown after the current navigation. |
{string} | oControlEvent.getParameters.toId | The ID of the page which will be shown after the current navigation. |
{boolean} | oControlEvent.getParameters.firstTime | Whether the "to" page (more precisely: a control with the ID of the page which is currently navigated to) has not been shown/navigated to before. |
{boolean} | oControlEvent.getParameters.isTo | Whether this is a forward navigation, triggered by "to()". |
{boolean} | oControlEvent.getParameters.isBack | Whether this is a back navigation, triggered by "back()". |
{boolean} | oControlEvent.getParameters.isBackToTop | Whether this is a navigation to the root page, triggered by "backToTop()". |
{boolean} | oControlEvent.getParameters.isBackToPage | Whether this was a navigation to a specific page, triggered by "backToPage()". |
{string} | oControlEvent.getParameters.direction | How the navigation was triggered, possible values are "to", "back", "backToPage", and "backToTop". |
- Since:
- 1.7.1
sClassName
and enriches it with the information contained in oClassInfo
. oClassInfo
might contain the same kind of information as described in sap.ui.core.Control.extend.
{string} | sClassName | Name of the class being created |
{object} | oClassInfo? | Object literal with information about the class |
{function} | FNMetaImpl? | Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata |
{function} | Created class / constructor function |
{sap.ui.base.Metadata} | Metadata object describing this class |
"to" and "back" are the transition functions for the forward and backward navigation. Both will be called with the following parameters: - oFromPage: the Control which is currently being displayed by the NavContainer - oToPage: the Control which should be displayed by the NavContainer after the transition - fCallback: a function which MUST be called when the transition has completed - oTransitionParameters: a data object that can be given by application code when triggering the transition by calling to() or back(); this object could give additional information to the transition function, like the DOM element which triggered the transition or the desired transition duration
The contract for "to" and "back" is that they may do an animation of their choice, but it should not take "too long". At the beginning of the transition the target page "oToPage" does have the CSS class "sapMNavItemHidden" which initially hides the target page (visibility:hidden). The transition can do any preparation (e.g. move that page out of the screen or make it transparent) and then should remove this CSS class. After the animation the target page "oToPage" should cover the entire screen and the source page "oFromPage" should not be visible anymore. This page should then have the CSS class "sapMNavItemHidden". For adding/removing this or other CSS classes, the transition can use the addStyleClass/removeStyleClass method: oFromPage.addStyleClass("sapMNavItemHidden"); When the transition is complete, it MUST call the given fCallback method to inform the NavContainer that navigation has finished!
Hint: if the target page of your transition stays black on iPhone, try wrapping the animation start into a setTimeout(..., 0) block (delayed, but without waiting).
This method can be called on any NavContainer instance or statically on the sap.m.NavContainer type. However, the transition will always be registered for the type (and ALL instances), not for the single instance on which this method was invoked.
Returns the sap.m.NavContainer type if called statically, or "this" (to allow method chaining) if called on a particular NavContainer instance.
{string} | sName | The name of the transition. This name can be used by the application to choose this transition when navigating "to()" or "back()": the "transitionName" parameter of "NavContainer.to()" corresponds to this name, the back() navigation will automatically use the same transition. Make sure to only use names that will not collide with transitions which may be added to the NavContainer later. A suggestion is to use the prefix "c_" or "_" for your custom transitions to ensure this. |
{object} | oTo | The function which will be called by the NavContainer when the application navigates "to()", using this animation's name. The NavContainer instance is the "this" context within the animation function. See the documentation of NavContainer.addCustomTransitions for more details about this function. |
{object} | oBack | The function which will be called by the NavContainer when the application navigates "back()" from a page where it had navigated to using this animation's name. The NavContainer instance is the "this" context within the animation function. See the documentation of NavContainer.addCustomTransitions for more details about this function. |
{sap.m.NavContainer} |
pages
. {sap.ui.core.Control} | oPage | the page to add; if empty, nothing is inserted |
{sap.m.NavContainer} | Reference to this in order to allow method chaining |
fnFunction
to the afterNavigate
event of this sap.m.NavContainer
. When called, the context of the event handler (its this
) will be bound to oListener
if specified, otherwise it will be bound to this sap.m.NavContainer
itself.
The event is fired when navigation between two pages has completed. In case of animated transitions this event is fired with some delay after the "navigate" event.
{object} | oData? | An application-specific payload object that will be passed to the event handler along with the event object when firing the event |
{function} | fnFunction | The function to be called when the event occurs |
{object} | oListener? | Context object to call the event handler with. Defaults to this sap.m.NavContainer itself |
- Since:
- 1.7.1
{sap.m.NavContainer} | Reference to this in order to allow method chaining |
fnFunction
to the navigate
event of this sap.m.NavContainer
. When called, the context of the event handler (its this
) will be bound to oListener
if specified, otherwise it will be bound to this sap.m.NavContainer
itself.
The event is fired when navigation between two pages has been triggered. The transition (if any) to the new page has not started yet. This event can be aborted by the application with preventDefault(), which means that there will be no navigation.
{object} | oData? | An application-specific payload object that will be passed to the event handler along with the event object when firing the event |
{function} | fnFunction | The function to be called when the event occurs |
{object} | oListener? | Context object to call the event handler with. Defaults to this sap.m.NavContainer itself |
- Since:
- 1.7.1
{sap.m.NavContainer} | Reference to this in order to allow method chaining |
Calling this navigation method triggers first the (cancelable) "navigate" event on the NavContainer, then the "beforeHide" pseudo event on the source page and "beforeFirstShow" (if applicable) and"beforeShow" on the target page. Later - after the transition has completed - the "afterShow" pseudo event is triggered on the target page and "afterHide" on the page which has been left. The given backData object is available in the "beforeFirstShow", "beforeShow" and "afterShow" event object as "data" property. The original "data" object from the "to" navigation is also available in these event objects.
{object} | oBackData? | Since version 1.7.1. This optional object can carry any payload data which should be made available to the target page of the back navigation. The event on the target page will contain this data object as "backData" property. (The original data from the "to()" navigation will still be available as "data" property.) In scenarios where the entity triggering the navigation can or should not directly initialize the target page, it can fill this object and the target page itself (or a listener on it) can take over the initialization, using the given data. For back navigation this can be used e.g. when returning from a detail page to transfer any settings done there. When the "transitionParameters" object is used, this "data" object must also be given (either as object or as null) in order to have a proper parameter order. |
{object} | oTransitionParameters? | Since version 1.7.1. This optional object can give additional information to the transition function, like the DOM element which triggered the transition or the desired transition duration. The animation type can NOT be selected here - it is always the inverse of the "to" navigation. In order to use the "transitionParameters" property, the "data" property must be used (at least "null" must be given) for a proper parameter order. NOTE: it depends on the transition function how the object should be structured and which parameters are actually used to influence the transition. |
{sap.m.NavContainer} |
Calling this navigation method triggers first the (cancelable) "navigate" event on the NavContainer, then the "beforeHide" pseudo event on the source page and "beforeFirstShow" (if applicable) and"beforeShow" on the target page. Later - after the transition has completed - the "afterShow" pseudo event is triggered on the target page and "afterHide" on the page which has been left. The given backData object is available in the "beforeFirstShow", "beforeShow" and "afterShow" event object as "data" property. The original "data" object from the "to" navigation is also available in these event objects.
{string} | sPageId | The ID of the screen to which back navigation should happen. The ID or the control itself can be given. The nearest such page among the previous pages in the history stack will be used. |
{object} | oBackData? | This optional object can carry any payload data which should be made available to the target page of the "backToPage" navigation. The event on the target page will contain this data object as "backData" property. When the "transitionParameters" object is used, this "data" object must also be given (either as object or as null) in order to have a proper parameter order. |
{object} | oTransitionParameters? | This optional object can give additional information to the transition function, like the DOM element which triggered the transition or the desired transition duration. The animation type can NOT be selected here - it is always the inverse of the "to" navigation. In order to use the "transitionParameters" property, the "data" property must be used (at least "null" must be given) for a proper parameter order. NOTE: it depends on the transition function how the object should be structured and which parameters are actually used to influence the transition. |
- Since:
- 1.7.2
{sap.m.NavContainer} |
Calling this navigation method triggers first the (cancelable) "navigate" event on the NavContainer, then the "beforeHide" pseudo event on the source page and "beforeFirstShow" (if applicable) and"beforeShow" on the target page. Later - after the transition has completed - the "afterShow" pseudo event is triggered on the target page and "afterHide" on the page which has been left. The given backData object is available in the "beforeFirstShow", "beforeShow" and "afterShow" event object as "data" property.
{object} | oBackData? | This optional object can carry any payload data which should be made available to the target page of the "backToTop" navigation. The event on the target page will contain this data object as "backData" property. When the "transitionParameters" object is used, this "data" object must also be given (either as object or as null) in order to have a proper parameter order. |
{object} | oTransitionParameters? | This optional object can give additional information to the transition function, like the DOM element which triggered the transition or the desired transition duration. The animation type can NOT be selected here - it is always the inverse of the "to" navigation. In order to use the "transitionParameters" property, the "data" property must be used (at least "null" must be given) for a proper parameter order. NOTE: it depends on the transition function how the object should be structured and which parameters are actually used to influence the transition. |
- Since:
- 1.7.1
{sap.m.NavContainer} |
Note: going to the initial page again with a row of "to" navigations causes the initial page to be displayed again, but logically one is not at the top level, so this method returns "false" in this case.
{boolean} |
pages
. {sap.m.NavContainer} | Reference to this in order to allow method chaining |
fnFunction
from the afterNavigate
event of this sap.m.NavContainer
. The passed function and listener object must match the ones used for event registration.
{function} | fnFunction | The function to be called, when the event occurs |
{object} | oListener | Context object on which the given function had to be called |
- Since:
- 1.7.1
{sap.m.NavContainer} | Reference to this in order to allow method chaining |
fnFunction
from the navigate
event of this sap.m.NavContainer
. The passed function and listener object must match the ones used for event registration.
{function} | fnFunction | The function to be called, when the event occurs |
{object} | oListener | Context object on which the given function had to be called |
- Since:
- 1.7.1
{sap.m.NavContainer} | Reference to this in order to allow method chaining |
afterNavigate
to attached listeners. Expects the following event parameters:
from
of typesap.ui.core.Control
The page which had been shown before navigation.fromId
of typestring
The ID of the page which had been shown before navigation.to
of typesap.ui.core.Control
The page which is now shown after navigation.toId
of typestring
The ID of the page which is now shown after navigation.firstTime
of typeboolean
Whether the "to" page (more precisely: a control with the ID of the page which has been navigated to) had not been shown/navigated to before.isTo
of typeboolean
Whether was a forward navigation, triggered by "to()".isBack
of typeboolean
Whether this was a back navigation, triggered by "back()".isBackToTop
of typeboolean
Whether this was a navigation to the root page, triggered by "backToTop()".isBackToPage
of typeboolean
Whether this was a navigation to a specific page, triggered by "backToPage()".direction
of typestring
How the navigation was triggered, possible values are "to", "back", "backToPage", and "backToTop".
{Map} | mArguments? | The arguments to pass along with the event |
- Since:
- 1.7.1
{sap.m.NavContainer} | Reference to this in order to allow method chaining |
navigate
to attached listeners. Listeners may prevent the default action of this event by using the preventDefault
-method on the event object.
Expects the following event parameters:
from
of typesap.ui.core.Control
The page which was shown before the current navigation.fromId
of typestring
The ID of the page which was shown before the current navigation.to
of typesap.ui.core.Control
The page which will be shown after the current navigation.toId
of typestring
The ID of the page which will be shown after the current navigation.firstTime
of typeboolean
Whether the "to" page (more precisely: a control with the ID of the page which is currently navigated to) has not been shown/navigated to before.isTo
of typeboolean
Whether this is a forward navigation, triggered by "to()".isBack
of typeboolean
Whether this is a back navigation, triggered by "back()".isBackToTop
of typeboolean
Whether this is a navigation to the root page, triggered by "backToTop()".isBackToPage
of typeboolean
Whether this was a navigation to a specific page, triggered by "backToPage()".direction
of typestring
How the navigation was triggered, possible values are "to", "back", "backToPage", and "backToTop".
{Map} | mArguments? | The arguments to pass along with the event |
- Since:
- 1.7.1
{boolean} | Whether or not to prevent the default action |
autoFocus
. Determines whether the initial focus is set automatically on first rendering and after navigating to a new page. This is useful when on touch devices the keyboard pops out due to the focus being automatically set on an input field. If necessary the "afterShow" event can be used to focus another element.
Default value is true
.
- Since:
- 1.30
{boolean} | Value of property autoFocus |
Returns undefined if no page has been added yet.
{sap.ui.core.Control} |
defaultTransitionName
. The type of the transition/animation to apply when "to()" is called without defining a transition type to use. The default is "slide". Other options are: "fade", "flip" and "show" - and the names of any registered custom transitions.
Default value is slide
.
- Since:
- 1.7.1
{string} | Value of property defaultTransitionName |
height
. The height of the NavContainer. Can be changed when the NavContainer should not cover the whole available area.
Default value is 100%
.
{sap.ui.core.CSSSize} | Value of property height |
initialPage
, or null
. {sap.ui.core.Control} |
{string} | sId | The ID of the aggregated control to find. |
{sap.ui.core.Control} |
pages
. The content entities between which this NavContainer navigates. These can be of type sap.m.Page, sap.ui.core.View, sap.m.Carousel or any other control with fullscreen/page semantics.
These aggregated controls will receive navigation events like beforeShow, they are documented in the pseudo interface sap.m.NavContainerChild
{sap.ui.core.Control[]} |
- Since:
- 1.7.1
{sap.ui.core.Control} |
visible
. Whether the NavContainer is visible.
Default value is true
.
{boolean} | Value of property visible |
width
. The width of the NavContainer. Can be changed when the NavContainer should not cover the whole available area.
Default value is 100%
.
{sap.ui.core.CSSSize} | Value of property width |
sap.ui.core.Control
in the aggregation pages
. and returns its index if found or -1 otherwise. {sap.ui.core.Control} | oPage | The page whose index is looked for |
{int} | The index of the provided control in the aggregation if found, or -1 otherwise |
pages
. {sap.ui.core.Control} | oPage | the page to insert; if empty, nothing is inserted |
{int} | iIndex | the 0 -based index the page should be inserted at; for a negative value of iIndex , the page is inserted at position 0; for a value greater than the current size of the aggregation, the page is inserted at the last position |
{sap.m.NavContainer} | Reference to this in order to allow method chaining |
This can be used for deep-linking when the user directly reached a drilldown detail page using a bookmark and then wants to navigate up in the drilldown hierarchy. Normally such a back navigation would not be possible because there is no previous page in the NavContainer's history stack.
{string} | sPageId | The ID of the control/page/screen which is inserted into the history stack. The respective control must be aggregated by the NavContainer, otherwise this will cause an error. |
{string} | sTransitionName? | The type of the transition/animation which would have been used to navigate from the (inserted) previous page to the current page. When navigating back, the inverse animation will be applied. This parameter can be omitted; then the default is "slide" (horizontal movement from the right). |
{object} | oData? | This optional object can carry any payload data which would have been given to the inserted previous page if the user would have done a normal forward navigation to it. |
- Since:
- 1.16.1
{sap.m.NavContainer} |
pages
. Additionally, it unregisters them from the hosting UIArea.
{sap.ui.core.Control[]} | An array of the removed elements (might be empty) |
pages
. {int|string|sap.ui.core.Control} | vPage | The pageto remove or its index or id |
{sap.ui.core.Control} | The removed page or null |
autoFocus
. Determines whether the initial focus is set automatically on first rendering and after navigating to a new page. This is useful when on touch devices the keyboard pops out due to the focus being automatically set on an input field. If necessary the "afterShow" event can be used to focus another element.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is true
.
{boolean} | bAutoFocus | New value for property autoFocus |
- Since:
- 1.30
{sap.m.NavContainer} | Reference to this in order to allow method chaining |
defaultTransitionName
. The type of the transition/animation to apply when "to()" is called without defining a transition type to use. The default is "slide". Other options are: "fade", "flip" and "show" - and the names of any registered custom transitions.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is slide
.
{string} | sDefaultTransitionName | New value for property defaultTransitionName |
- Since:
- 1.7.1
{sap.m.NavContainer} | Reference to this in order to allow method chaining |
height
. The height of the NavContainer. Can be changed when the NavContainer should not cover the whole available area.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is 100%
.
{sap.ui.core.CSSSize} | sHeight | New value for property height |
{sap.m.NavContainer} | Reference to this in order to allow method chaining |
initialPage
. {sap.ui.core.Control} | oInitialPage | Id of an element which becomes the new target of this initialPage association; alternatively, an element instance may be given |
{sap.m.NavContainer} | Reference to this in order to allow method chaining |
visible
. Whether the NavContainer is visible.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is true
.
{boolean} | bVisible | New value for property visible |
{sap.m.NavContainer} | Reference to this in order to allow method chaining |
width
. The width of the NavContainer. Can be changed when the NavContainer should not cover the whole available area.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is 100%
.
{sap.ui.core.CSSSize} | sWidth | New value for property width |
{sap.m.NavContainer} | Reference to this in order to allow method chaining |
Note that any modifications to the target page (like setting its title, or anything else that could cause a re-rendering) should be done BEFORE calling to(), in order to avoid unwanted side effects, e.g. related to the page animation.
Available transitions currently include "slide" (default), "fade", "flip", and "show". None of these is currently making use of any given transitionParameters.
Calling this navigation method triggers first the (cancelable) "navigate" event on the NavContainer, then the "beforeHide" pseudo event on the source page and "beforeFirstShow" (if applicable) and"beforeShow" on the target page. Later - after the transition has completed - the "afterShow" pseudo event is triggered on the target page and "afterHide" on the page which has been left. The given data object is available in the "beforeFirstShow", "beforeShow" and "afterShow" event object as "data" property.
{string} | sPageId | The screen to which drilldown should happen. The ID or the control itself can be given. |
{string} | sTransitionName? | The type of the transition/animation to apply. This parameter can be omitted; then the default is "slide" (horizontal movement from the right). Other options are: "fade", "flip", and "show" and the names of any registered custom transitions. None of the standard transitions is currently making use of any given transition parameters. |
{object} | oData? | Since version 1.7.1. This optional object can carry any payload data which should be made available to the target page. The "beforeShow" event on the target page will contain this data object as "data" property. Use case: in scenarios where the entity triggering the navigation can or should not directly initialize the target page, it can fill this object and the target page itself (or a listener on it) can take over the initialization, using the given data. When the "transitionParameters" object is used, this "data" object must also be given (either as object or as null) in order to have a proper parameter order. |
{object} | oTransitionParameters? | Since version 1.7.1. This optional object can contain additional information for the transition function, like the DOM element which triggered the transition or the desired transition duration. For a proper parameter order, the "data" parameter must be given when the "transitionParameters" parameter is used. (it can be given as "null") NOTE: it depends on the transition function how the object should be structured and which parameters are actually used to influence the transition. The "show", "slide" and "fade" transitions do not use any parameter. |
{sap.m.NavContainer} |