function prepareSelection(oPlugin, iIndexFrom, iIndexTo, bAddSelection) {
		var iHighestSelectableIndex = oPlugin._getHighestSelectableIndex();

		if (iIndexFrom < 0 && iIndexTo < 0 || iIndexFrom > iHighestSelectableIndex && iIndexTo > iHighestSelectableIndex) {
			// Selection is not possible if the index range it completely out of the selectable range.
			return Promise.reject(new Error("Out of range"));
		}

		// Restrict indices to boundaries.
		iIndexFrom = Math.min(Math.max(0, iIndexFrom), iHighestSelectableIndex);
		iIndexTo = Math.min(Math.max(0, iIndexTo), iHighestSelectableIndex);

		var iLimit = oPlugin.getLimit();
		var bReverse = iIndexTo < iIndexFrom; // Indicates whether the selection is made from bottom to top.
		var iGetContextsStartIndex = bReverse ? iIndexTo : iIndexFrom;
		var iGetContextsLength;

		// If the start index is already selected, the range starts from the next index.
		if (bAddSelection && oPlugin.isIndexSelected(iIndexFrom)) {
			if (bReverse) {
				iIndexFrom--;
			} else if (iIndexFrom !== iIndexTo) {
				iIndexFrom++;
				iGetContextsStartIndex++;
			}
		}

		iGetContextsLength = Math.abs(iIndexTo - iIndexFrom) + 1;

		if (!oPlugin._bLimitDisabled) {
			oPlugin.setLimitReached(iGetContextsLength > iLimit);

			if (oPlugin.isLimitReached()) {
				if (bReverse) {
					iIndexTo = iIndexFrom - iLimit + 1;
				} else {
					iIndexTo = iIndexFrom + iLimit - 1;
				}

				// The table will be scrolled one row further to make it transparent for the user where the selection ends.
				// load the extra row here to avoid additional batch request.
				iGetContextsLength = iLimit + 1;
			}
		}

		return loadMultipleContexts(oPlugin.getTableBinding(), iGetContextsStartIndex, iGetContextsLength).then(function () {
			return {indexFrom: iIndexFrom, indexTo: iIndexTo};
		});
	}
/**
	 * Calculates the correct start and end index for the range selection and loads the corresponding contexts.
	 *
	 * @param {sap.ui.table.plugins.MultiSelectionPlugin} oPlugin The selection plugin.
	 * @param {int} iIndexFrom The start index of the range selection.
	 * @param {int} iIndexTo The end index of the range selection.
	 * @param {boolean} [bAddSelection=false] Whether to prepare for adding or setting the selection.
	 * @return {Promise|Promise<{indexTo: int, indexFrom: int}>} A promise that resolves with the corrected start and end index when the contexts are
	 * loaded. The Promise is rejected if the index is out of range.
	 */
Calculates the correct start and end index for the range selection and loads the corresponding contexts.
@param {sap.ui.table.plugins.MultiSelectionPlugin} oPlugin The selection plugin.
@param {int} iIndexFrom The start index of the range selection.
@param {int} iIndexTo The end index of the range selection.
@param {boolean} [bAddSelection=false] Whether to prepare for adding or setting the selection.
@return {Promise|Promise<{indexTo: int, indexFrom: int}>} A promise that resolves with the corrected start and end index when the contexts are
loaded. The Promise is rejected if the index is out of range.
Calculates the correct start and end index for the range selection and loads the corresponding contexts . @param { sap . ui . table . plugins . MultiSelectionPlugin } oPlugin The selection plugin . @param { int } iIndexFrom The start index of the range selection . @param { int } iIndexTo The end index of the range selection . @param { boolean } [ bAddSelection = false ] Whether to prepare for adding or setting the selection . @return { Promise|Promise< { indexTo : int indexFrom : int } > } A promise that resolves with the corrected start and end index when the contexts are loaded . The Promise is rejected if the index is out of range .
function prepareSelection(oPlugin, iIndexFrom, iIndexTo, bAddSelection) {
		var iHighestSelectableIndex = oPlugin._getHighestSelectableIndex();
		if (iIndexFrom < 0 && iIndexTo < 0 || iIndexFrom > iHighestSelectableIndex && iIndexTo > iHighestSelectableIndex) {
			return Promise.reject(new Error("Out of range"));
		}
		iIndexFrom = Math.min(Math.max(0, iIndexFrom), iHighestSelectableIndex);
		iIndexTo = Math.min(Math.max(0, iIndexTo), iHighestSelectableIndex);
		var iLimit = oPlugin.getLimit();
		var bReverse = iIndexTo < iIndexFrom; 
		var iGetContextsStartIndex = bReverse ? iIndexTo : iIndexFrom;
		var iGetContextsLength;
		if (bAddSelection && oPlugin.isIndexSelected(iIndexFrom)) {
			if (bReverse) {
				iIndexFrom--;
			} else if (iIndexFrom !== iIndexTo) {
				iIndexFrom++;
				iGetContextsStartIndex++;
			}
		}
		iGetContextsLength = Math.abs(iIndexTo - iIndexFrom) + 1;
		if (!oPlugin._bLimitDisabled) {
			oPlugin.setLimitReached(iGetContextsLength > iLimit);
			if (oPlugin.isLimitReached()) {
				if (bReverse) {
					iIndexTo = iIndexFrom - iLimit + 1;
				} else {
					iIndexTo = iIndexFrom + iLimit - 1;
				}
				iGetContextsLength = iLimit + 1;
			}
		}
		return loadMultipleContexts(oPlugin.getTableBinding(), iGetContextsStartIndex, iGetContextsLength).then(function () {
			return {indexFrom: iIndexFrom, indexTo: iIndexTo};
		});
	}
function prepareSelection ( oPlugin , iIndexFrom , iIndexTo , bAddSelection ) { var iHighestSelectableIndex = oPlugin . _getHighestSelectableIndex ( ) ; if ( iIndexFrom < 0 && iIndexTo < 0 || iIndexFrom > iHighestSelectableIndex && iIndexTo > iHighestSelectableIndex ) { return Promise . reject ( new Error ( "Out of range" ) ) ; } iIndexFrom = Math . min ( Math . max ( 0 , iIndexFrom ) , iHighestSelectableIndex ) ; iIndexTo = Math . min ( Math . max ( 0 , iIndexTo ) , iHighestSelectableIndex ) ; var iLimit = oPlugin . getLimit ( ) ; var bReverse = iIndexTo < iIndexFrom ; var iGetContextsStartIndex = bReverse ? iIndexTo : iIndexFrom ; var iGetContextsLength ; if ( bAddSelection && oPlugin . isIndexSelected ( iIndexFrom ) ) { if ( bReverse ) { iIndexFrom -- ; } else if ( iIndexFrom !== iIndexTo ) { iIndexFrom ++ ; iGetContextsStartIndex ++ ; } } iGetContextsLength = Math . abs ( iIndexTo - iIndexFrom ) + 1 ; if ( ! oPlugin . _bLimitDisabled ) { oPlugin . setLimitReached ( iGetContextsLength > iLimit ) ; if ( oPlugin . isLimitReached ( ) ) { if ( bReverse ) { iIndexTo = iIndexFrom - iLimit + 1 ; } else { iIndexTo = iIndexFrom + iLimit - 1 ; } iGetContextsLength = iLimit + 1 ; } } return loadMultipleContexts ( oPlugin . getTableBinding ( ) , iGetContextsStartIndex , iGetContextsLength ) . then ( function ( ) { return { indexFrom : iIndexFrom , indexTo : iIndexTo } ; } ) ; }
Calculates the correct start and end index for the range selection and loads the corresponding contexts.
Calculates the correct start and end index for the range selection and loads the corresponding contexts .
// Selection is not possible if the index range it completely out of the selectable range. // Restrict indices to boundaries. // Indicates whether the selection is made from bottom to top. // If the start index is already selected, the range starts from the next index. // The table will be scrolled one row further to make it transparent for the user where the selection ends. // load the extra row here to avoid additional batch request.