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


Constructor Summary
new sap.ui.model.SelectionModel(iSelectionMode)Constructs an instance of an 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 an sap.ui.model.SelectionModel.
Parameters:
intiSelectionModesap.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:
stringsClassNameName of the class being created
objectoClassInfo?Object literal with information about the class
functionFNMetaImpl?Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
functionCreated 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.MetadataMetadata 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:
intiFromIndexone end of the interval.
intiToIndexother end of the interval
Returns:
sap.ui.model.SelectionModelthis 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:
objectoData?The object, that should be passed along with the event-object when firing the event.
functionfnFunctionThe function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'.
objectoListener?Object on which to call the given function. If empty, this Model is used.
Returns:
sap.ui.model.SelectionModelthis 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.SelectionModelthis 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:
functionfnFunctionThe function to call, when the event occurs.
objectoListenerObject on which the given function had to be called.
Returns:
sap.ui.model.SelectionModelthis 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:
objectmArgumentsthe arguments to pass along with the event.
intmArguments.leadIndexLead selection index
int[]mArguments.rowIndices?Other selected indices (if available)
Returns:
sap.ui.model.SelectionModelthis to allow method chaining
getLeadSelectedIndex(): int
Return the second index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().
Returns:
intlead selected index
getSelectedIndices(): int[]
Returns the selected indices as array.
Returns:
int[]array of selected indices
getSelectionMode(): int
Returns the current selection mode.
Returns:
intthe current selection mode
isSelectedIndex(iIndex): boolean
Returns true if the specified index is selected.
Parameters:
intiIndex
Returns:
booleantrue 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:
intiStartIndexstart at this position
intiMove
Returns:
sap.ui.model.SelectionModelthis 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:
intiFromIndexone end of the interval.
intiToIndexother end of the interval
Returns:
sap.ui.model.SelectionModelthis 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:
intiToIndexend of the interval
Returns:
sap.ui.model.SelectionModelthis 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:
intiFromIndexone end of the interval.
intiToIndexother end of the interval
Returns:
sap.ui.model.SelectionModelthis 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:
intiSelectionModeselection 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:
intiFromIndexone end of the interval.
intiToIndexother end of the interval
Returns:
sap.ui.model.SelectionModelthis to allow method chaining