function _applyChange(oChange, oRelevantContainer, mPropertyBag, fnIterator) {
		var oModifier = mPropertyBag.modifier,
			oView = mPropertyBag.view,
			oAppComponent = mPropertyBag.appComponent,
			oChangeContent = oChange.getContent(),
			oTargetSource = oChange.getDependentControl(SOURCE_ALIAS, mPropertyBag),
			oTable = oChange.getDependentControl(TARGET_ALIAS, mPropertyBag),
			aColumns = oModifier.getAggregation(oTable, COLUMNS_AGGREGATION_NAME),
			switchCells = function (oRow, iSourceIndex, iTargetIndex) {
				var aCells = oModifier.getAggregation(oRow, CELLS_AGGREGATION_NAME);

				// ColumnListItem and GroupHeaderListItem are only allowed for the tables items aggregation.
				if (!aCells) {
					Log.warning("Aggregation cells to move not found");
					return;
				}

				if (iSourceIndex < 0 || iSourceIndex >= aCells.length) {
					Log.warning("Move cells in table item called with invalid index: " + iSourceIndex);
					return;
				}

				var oMovedCell = aCells[iSourceIndex];
				oModifier.removeAggregation(oRow, CELLS_AGGREGATION_NAME, oMovedCell);
				oModifier.insertAggregation(oRow, CELLS_AGGREGATION_NAME, oMovedCell, iTargetIndex, oView);
			},
			moveColumns = function (iSourceIndex, iTargetIndex) {
				oModifier.getAggregation(oTable, ITEMS_AGGREGATION_NAME).forEach(function (oItem) {
					// We are skipping the GroupHeaderListItems, because they are valid for the whole row and does not have cells to move.
					if (oModifier.getControlType(oItem) === "sap.m.GroupHeaderListItem") {
						return;
					}

					switchCells(oItem, iSourceIndex, iTargetIndex);
				});
			};

		if (oTargetSource !== oTable) {
			Log.warning("Moving columns between different tables is not yet supported.");
			return false;
		}

		// Fetch the information about the movedElements together with the source and target index.
		oChangeContent.movedElements.forEach(function (mMovedElement) {
			var oMovedElement = oModifier.bySelector(mMovedElement.selector, oAppComponent, oView),
				iSourceIndex, iTargetIndex, iCurrentIndexInAggregation, iStoredSourceIndexInChange, sMovedElementId;

			if (!oMovedElement) {
				sMovedElementId = mMovedElement.selector && mMovedElement.selector.id;
				Log.warning("The table column with id: '" + sMovedElementId + "' stored in the change is not found and the move operation cannot be applied");
				return;
			}

			iCurrentIndexInAggregation = aColumns.indexOf(oMovedElement);
			iStoredSourceIndexInChange = mMovedElement.sourceIndex;
			iTargetIndex = jQuery.isFunction(fnIterator) && fnIterator(iCurrentIndexInAggregation);
			iTargetIndex = jQuery.isNumeric(iTargetIndex) ? iTargetIndex : mMovedElement.targetIndex;

			if (iCurrentIndexInAggregation !== iTargetIndex) {
				// By default we are getting the index from the aggregation, because it is possible that the order is
				// already modified and the column that we want to move is not on the passed source index
				iSourceIndex = iCurrentIndexInAggregation;
			} else {
				// In RTA edit mode, the condition will be false, because the aggregation is modified by the drag and drop action.
				// Therefore, we need to use the passed source index
				iSourceIndex = iStoredSourceIndexInChange;
			}

			// move children in `columns` aggregation
			oModifier.removeAggregation(oTable, COLUMNS_AGGREGATION_NAME, oMovedElement);
			oModifier.insertAggregation(oTable, COLUMNS_AGGREGATION_NAME, oMovedElement, iTargetIndex, oView);

			// move children in `items` aggregation (actual content)
			var oTemplate = oModifier.getBindingTemplate(oTable, ITEMS_AGGREGATION_NAME);

			if (oTemplate) {
				switchCells(oTemplate, iSourceIndex, iTargetIndex);
				oModifier.updateAggregation(oTable, ITEMS_AGGREGATION_NAME);
			} else {
				moveColumns(iSourceIndex, iTargetIndex);
			}
		}, this);

		return true;
	}
function _applyChange(oChange, oRelevantContainer, mPropertyBag, fnIterator) {
		var oModifier = mPropertyBag.modifier,
			oView = mPropertyBag.view,
			oAppComponent = mPropertyBag.appComponent,
			oChangeContent = oChange.getContent(),
			oTargetSource = oChange.getDependentControl(SOURCE_ALIAS, mPropertyBag),
			oTable = oChange.getDependentControl(TARGET_ALIAS, mPropertyBag),
			aColumns = oModifier.getAggregation(oTable, COLUMNS_AGGREGATION_NAME),
			switchCells = function (oRow, iSourceIndex, iTargetIndex) {
				var aCells = oModifier.getAggregation(oRow, CELLS_AGGREGATION_NAME);

				// ColumnListItem and GroupHeaderListItem are only allowed for the tables items aggregation.
				if (!aCells) {
					Log.warning("Aggregation cells to move not found");
					return;
				}

				if (iSourceIndex < 0 || iSourceIndex >= aCells.length) {
					Log.warning("Move cells in table item called with invalid index: " + iSourceIndex);
					return;
				}

				var oMovedCell = aCells[iSourceIndex];
				oModifier.removeAggregation(oRow, CELLS_AGGREGATION_NAME, oMovedCell);
				oModifier.insertAggregation(oRow, CELLS_AGGREGATION_NAME, oMovedCell, iTargetIndex, oView);
			},
			moveColumns = function (iSourceIndex, iTargetIndex) {
				oModifier.getAggregation(oTable, ITEMS_AGGREGATION_NAME).forEach(function (oItem) {
					// We are skipping the GroupHeaderListItems, because they are valid for the whole row and does not have cells to move.
					if (oModifier.getControlType(oItem) === "sap.m.GroupHeaderListItem") {
						return;
					}

					switchCells(oItem, iSourceIndex, iTargetIndex);
				});
			};

		if (oTargetSource !== oTable) {
			Log.warning("Moving columns between different tables is not yet supported.");
			return false;
		}

		// Fetch the information about the movedElements together with the source and target index.
		oChangeContent.movedElements.forEach(function (mMovedElement) {
			var oMovedElement = oModifier.bySelector(mMovedElement.selector, oAppComponent, oView),
				iSourceIndex, iTargetIndex, iCurrentIndexInAggregation, iStoredSourceIndexInChange, sMovedElementId;

			if (!oMovedElement) {
				sMovedElementId = mMovedElement.selector && mMovedElement.selector.id;
				Log.warning("The table column with id: '" + sMovedElementId + "' stored in the change is not found and the move operation cannot be applied");
				return;
			}

			iCurrentIndexInAggregation = aColumns.indexOf(oMovedElement);
			iStoredSourceIndexInChange = mMovedElement.sourceIndex;
			iTargetIndex = jQuery.isFunction(fnIterator) && fnIterator(iCurrentIndexInAggregation);
			iTargetIndex = jQuery.isNumeric(iTargetIndex) ? iTargetIndex : mMovedElement.targetIndex;

			if (iCurrentIndexInAggregation !== iTargetIndex) {
				// By default we are getting the index from the aggregation, because it is possible that the order is
				// already modified and the column that we want to move is not on the passed source index
				iSourceIndex = iCurrentIndexInAggregation;
			} else {
				// In RTA edit mode, the condition will be false, because the aggregation is modified by the drag and drop action.
				// Therefore, we need to use the passed source index
				iSourceIndex = iStoredSourceIndexInChange;
			}

			// move children in `columns` aggregation
			oModifier.removeAggregation(oTable, COLUMNS_AGGREGATION_NAME, oMovedElement);
			oModifier.insertAggregation(oTable, COLUMNS_AGGREGATION_NAME, oMovedElement, iTargetIndex, oView);

			// move children in `items` aggregation (actual content)
			var oTemplate = oModifier.getBindingTemplate(oTable, ITEMS_AGGREGATION_NAME);

			if (oTemplate) {
				switchCells(oTemplate, iSourceIndex, iTargetIndex);
				oModifier.updateAggregation(oTable, ITEMS_AGGREGATION_NAME);
			} else {
				moveColumns(iSourceIndex, iTargetIndex);
			}
		}, this);

		return true;
	}
function _applyChange ( oChange , oRelevantContainer , mPropertyBag , fnIterator ) { var oModifier = mPropertyBag . modifier , oView = mPropertyBag . view , oAppComponent = mPropertyBag . appComponent , oChangeContent = oChange . getContent ( ) , oTargetSource = oChange . getDependentControl ( SOURCE_ALIAS , mPropertyBag ) , oTable = oChange . getDependentControl ( TARGET_ALIAS , mPropertyBag ) , aColumns = oModifier . getAggregation ( oTable , COLUMNS_AGGREGATION_NAME ) , switchCells = function ( oRow , iSourceIndex , iTargetIndex ) { var aCells = oModifier . getAggregation ( oRow , CELLS_AGGREGATION_NAME ) ; // ColumnListItem and GroupHeaderListItem are only allowed for the tables items aggregation. if ( ! aCells ) { Log . warning ( "Aggregation cells to move not found" ) ; return ; } if ( iSourceIndex < 0 || iSourceIndex >= aCells . length ) { Log . warning ( "Move cells in table item called with invalid index: " + iSourceIndex ) ; return ; } var oMovedCell = aCells [ iSourceIndex ] ; oModifier . removeAggregation ( oRow , CELLS_AGGREGATION_NAME , oMovedCell ) ; oModifier . insertAggregation ( oRow , CELLS_AGGREGATION_NAME , oMovedCell , iTargetIndex , oView ) ; } , moveColumns = function ( iSourceIndex , iTargetIndex ) { oModifier . getAggregation ( oTable , ITEMS_AGGREGATION_NAME ) . forEach ( function ( oItem ) { // We are skipping the GroupHeaderListItems, because they are valid for the whole row and does not have cells to move. if ( oModifier . getControlType ( oItem ) === "sap.m.GroupHeaderListItem" ) { return ; } switchCells ( oItem , iSourceIndex , iTargetIndex ) ; } ) ; } ; if ( oTargetSource !== oTable ) { Log . warning ( "Moving columns between different tables is not yet supported." ) ; return false ; } // Fetch the information about the movedElements together with the source and target index. oChangeContent . movedElements . forEach ( function ( mMovedElement ) { var oMovedElement = oModifier . bySelector ( mMovedElement . selector , oAppComponent , oView ) , iSourceIndex , iTargetIndex , iCurrentIndexInAggregation , iStoredSourceIndexInChange , sMovedElementId ; if ( ! oMovedElement ) { sMovedElementId = mMovedElement . selector && mMovedElement . selector . id ; Log . warning ( "The table column with id: '" + sMovedElementId + "' stored in the change is not found and the move operation cannot be applied" ) ; return ; } iCurrentIndexInAggregation = aColumns . indexOf ( oMovedElement ) ; iStoredSourceIndexInChange = mMovedElement . sourceIndex ; iTargetIndex = jQuery . isFunction ( fnIterator ) && fnIterator ( iCurrentIndexInAggregation ) ; iTargetIndex = jQuery . isNumeric ( iTargetIndex ) ? iTargetIndex : mMovedElement . targetIndex ; if ( iCurrentIndexInAggregation !== iTargetIndex ) { // By default we are getting the index from the aggregation, because it is possible that the order is // already modified and the column that we want to move is not on the passed source index iSourceIndex = iCurrentIndexInAggregation ; } else { // In RTA edit mode, the condition will be false, because the aggregation is modified by the drag and drop action. // Therefore, we need to use the passed source index iSourceIndex = iStoredSourceIndexInChange ; } // move children in `columns` aggregation oModifier . removeAggregation ( oTable , COLUMNS_AGGREGATION_NAME , oMovedElement ) ; oModifier . insertAggregation ( oTable , COLUMNS_AGGREGATION_NAME , oMovedElement , iTargetIndex , oView ) ; // move children in `items` aggregation (actual content) var oTemplate = oModifier . getBindingTemplate ( oTable , ITEMS_AGGREGATION_NAME ) ; if ( oTemplate ) { switchCells ( oTemplate , iSourceIndex , iTargetIndex ) ; oModifier . updateAggregation ( oTable , ITEMS_AGGREGATION_NAME ) ; } else { moveColumns ( iSourceIndex , iTargetIndex ) ; } } , this ) ; return true ; }
Moves a column from one index to another.
@param {sap.ui.fl.Change} oChange Change object with instructions to be applied on the control
@param {sap.ui.core.Control} oRelevantContainer Control that matches the change selector for applying the change, which is the source of the move
@param {object} mPropertyBag Map of properties
@param {object} mPropertyBag.view XML node representing a ui5 view
@param {sap.ui.core.util.reflection.BaseTreeModifier} mPropertyBag.modifier Modifier for the controls
@param {sap.ui.core.UIComponent} mPropertyBag.appComponent AppComponent
@param {function} fnIterator - Iterator function which is called on each movedElement, as an argument it gets CurrentIndex
of the element and may return TargetIndex as a result.
@return {boolean} true Indicates whether the change can be applied
Moves a column from one index to another .
Applies a change to the given container.