Class sap.ui.model.SelectionModelModule: sap/ui/model/SelectionModel


Constructor Summary
new sap.ui.model.SelectionModel(iSelectionMode)Constructs an instance of a sap.ui.model.SelectionModel.
Field Summary
sap.ui.model.SelectionModel.MULTI_SELECTIONSelectionMode: Multi Selection
sap.ui.model.SelectionModel.SINGLE_SELECTIONSelectionMode: Single Selection
Method Summary
sap.ui.model.SelectionModel.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.model.SelectionModel with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.model.SelectionModel.getMetadata()Returns a metadata object for class sap.ui.model.SelectionModel.
addSelectionInterval(iFromIndex, iToIndex)Changes the selection to be the union of the current selection and the range between iFromIndex and iToIndex inclusive.
attachSelectionChanged(oData?, fnFunction, oListener?)Attach event-handler fnFunction to the 'selectionChanged' event of this sap.ui.model.SelectionModel.
clearSelection()Change the selection to the empty set and clears the lead selection.
detachSelectionChanged(fnFunction, oListener)Detach event-handler fnFunction from the 'selectionChanged' event of this sap.ui.model.SelectionModel.
fireSelectionChanged(mArguments)Fire event 'selectionChanged' to attached listeners.
getLeadSelectedIndex()Return the second index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().
getSelectedIndices()Returns the selected indices as array.
getSelectionMode()Returns the current selection mode.
isSelectedIndex(iIndex)Returns true if the specified index is selected.
moveSelectionInterval(iStartIndex, iMove)Moves all selected indices starting at the position iStartIndexiMove items.
removeSelectionInterval(iFromIndex, iToIndex)Changes the selection to be the set difference of the current selection and the indices between iFromIndex and iToIndex inclusive.
selectAll(iToIndex)Selects all rows up to the iToIndex.
setSelectionInterval(iFromIndex, iToIndex)Changes the selection to be equal to the range iFromIndex and iToIndex inclusive.
setSelectionMode(iSelectionMode)Sets the selection mode.
sliceSelectionInterval(iFromIndex, iToIndex)Slices a the indices between the two indices from the selection.
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.model.SelectionModel(iSelectionMode)
Constructs an instance of a sap.ui.model.SelectionModel.
Parameters:
{int}iSelectionModesap.ui.model.SelectionModel.SINGLE_SELECTION or sap.ui.model.SelectionModel.MULTI_SELECTION
Field Detail
sap.ui.model.SelectionModel.MULTI_SELECTION
SelectionMode: Multi Selection
sap.ui.model.SelectionModel.SINGLE_SELECTION
SelectionMode: Single Selection
Method Detail
sap.ui.model.SelectionModel.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.model.SelectionModel with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.base.EventProvider.extend.

Parameters:
{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
Returns:
{function} Created class / constructor function
sap.ui.model.SelectionModel.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.model.SelectionModel.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
addSelectionInterval(iFromIndex, iToIndex): sap.ui.model.SelectionModel
Changes the selection to be the union of the current selection and the range between iFromIndex and iToIndex inclusive. If iFromIndex is smaller than iToIndex, both parameters are swapped.

In SINGLE_SELECTION selection mode, this is equivalent to calling setSelectionInterval, and only the second index is used.

If this call results in a change to the current selection or lead selection, then a SelectionChanged event is fired.

Parameters:
{int}iFromIndex one end of the interval.
{int}iToIndex other end of the interval
Returns:
{sap.ui.model.SelectionModel}this to allow method chaining
attachSelectionChanged(oData?, fnFunction, oListener?): sap.ui.model.SelectionModel
Attach event-handler fnFunction to the 'selectionChanged' event of this sap.ui.model.SelectionModel.
Parameters:
{object}oData? The object, that should be passed along with the event-object when firing the event.
{function}fnFunction The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'.
{object}oListener? Object on which to call the given function. If empty, this Model is used.
Returns:
{sap.ui.model.SelectionModel}this to allow method chaining
clearSelection(): sap.ui.model.SelectionModel
Change the selection to the empty set and clears the lead selection.

If this call results in a change to the current selection or lead selection, then a SelectionChanged event is fired.

Returns:
{sap.ui.model.SelectionModel}this to allow method chaining
detachSelectionChanged(fnFunction, oListener): sap.ui.model.SelectionModel
Detach event-handler fnFunction from the 'selectionChanged' event of this sap.ui.model.SelectionModel.

The passed function and listener object must match the ones previously used for event registration.

Parameters:
{function}fnFunction The function to call, when the event occurs.
{object}oListener Object on which the given function had to be called.
Returns:
{sap.ui.model.SelectionModel}this to allow method chaining
fireSelectionChanged(mArguments): sap.ui.model.SelectionModel
Fire event 'selectionChanged' to attached listeners.

Expects following event parameters:

  • 'leadIndex' of type int Lead selection index.
  • 'rowIndices' of type int[] Other selected indices (if available)
Parameters:
{object}mArguments the arguments to pass along with the event.
{int}mArguments.leadIndex Lead selection index
{int[]}mArguments.rowIndices? Other selected indices (if available)
Returns:
{sap.ui.model.SelectionModel}this to allow method chaining
getLeadSelectedIndex(): int
Return the second index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().
Returns:
{int} lead selected index
getSelectedIndices(): int[]
Returns the selected indices as array.
Returns:
{int[]} array of selected indices
getSelectionMode(): int
Returns the current selection mode.
Returns:
{int} the current selection mode
isSelectedIndex(iIndex): boolean
Returns true if the specified index is selected.
Parameters:
{int}iIndex
Returns:
{boolean} true if the specified index is selected.
moveSelectionInterval(iStartIndex, iMove): sap.ui.model.SelectionModel
Moves all selected indices starting at the position iStartIndexiMove items.

This can be used if new items are inserted to the item set and you want to keep the selection. To handle a deletion of items use sliceSelectionInterval.

If this call results in a change to the current selection or lead selection, then a SelectionChanged event is fired.

Parameters:
{int}iStartIndex start at this position
{int}iMove
Returns:
{sap.ui.model.SelectionModel}this to allow method chaining
removeSelectionInterval(iFromIndex, iToIndex): sap.ui.model.SelectionModel
Changes the selection to be the set difference of the current selection and the indices between iFromIndex and iToIndex inclusive. If iFromIndex is smaller than iToIndex, both parameters are swapped.

If the range of removed selection indices includes the current lead selection, then the lead selection will be unset (set to -1).

If this call results in a change to the current selection or lead selection, then a SelectionChanged event is fired.

Parameters:
{int}iFromIndex one end of the interval.
{int}iToIndex other end of the interval
Returns:
{sap.ui.model.SelectionModel}this to allow method chaining
selectAll(iToIndex): sap.ui.model.SelectionModel
Selects all rows up to the iToIndex.

If this call results in a change to the current selection, then a SelectionChanged event is fired.

Parameters:
{int}iToIndex end of the interval
Returns:
{sap.ui.model.SelectionModel}this to allow method chaining
setSelectionInterval(iFromIndex, iToIndex): sap.ui.model.SelectionModel
Changes the selection to be equal to the range iFromIndex and iToIndex inclusive. If iFromIndex is smaller than iToIndex, both parameters are swapped.

In SINGLE_SELECTION selection mode, only iToIndex is used.

If this call results in a change to the current selection, then a SelectionChanged event is fired.

Parameters:
{int}iFromIndex one end of the interval.
{int}iToIndex other end of the interval
Returns:
{sap.ui.model.SelectionModel}this to allow method chaining
setSelectionMode(iSelectionMode)
Sets the selection mode. The following list describes the accepted selection modes:
  • sap.ui.model.SelectionModel.SINGLE_SELECTION - Only one list index can be selected at a time. In this mode, setSelectionInterval and addSelectionInterval are equivalent, both replacing the current selection with the index represented by the second argument (the "lead").
  • sap.ui.model.SelectionModel.MULTI_SELECTION - In this mode, there's no restriction on what can be selected.
Parameters:
{int}iSelectionMode selection mode
sliceSelectionInterval(iFromIndex, iToIndex): sap.ui.model.SelectionModel
Slices a the indices between the two indices from the selection. If iFromIndex is smaller than iToIndex, both parameters are swapped.

If the range of removed selection indices includes the current lead selection, then the lead selection will be unset (set to -1).

If this call results in a change to the current selection or lead selection, then a SelectionChanged event is fired.

Parameters:
{int}iFromIndex one end of the interval.
{int}iToIndex other end of the interval
Returns:
{sap.ui.model.SelectionModel}this to allow method chaining