Recently, I came across a scenario in SAP Fiori Elements List Report Object Page (LROP) where I need to filter the List Report table data in entity1 based on the Object page data in entity2.

Added a custom filter extension binding the entity2 to the sap.m.MultiComboBox control in List Report:

Given a number to length as I am getting only 1st 100 records. Now, I need to filter the List Report table holding entity1 data. Here in both the entities, there is a common field carrid which I gave as a key to MultiComboBox.

Here is the code I wrote in onBeforeRebindTableExtension method placed inside ListReportExt.controller.js to achieve my requirement.

	onBeforeRebindTableExtension: function (oEvent) {
		debugger;
		var customFilterItems = this.getView().byId(
				"com.zlistreportobjectsample9::sap.suite.ui.generic.template.ListReport.view.ListReport::YTEST_FLIGHT_LIST--maxspace").getItems(),
			mBindingParams = oEvent.getParameter("bindingParams"),
			aSelectedItems = this.getView().byId(
				"com.zlistreportobjectsample9::sap.suite.ui.generic.template.ListReport.view.ListReport::YTEST_FLIGHT_LIST--maxspace").getSelectedItems(),
			aSelectedItemsArray = [],
			aItemsArray = [];

		aSelectedItems.forEach(function (oSelectedItem) {
			aSelectedItemsArray.push(oSelectedItem.getText());
		});

		customFilterItems.forEach(function (oItem) {
			aSelectedItemsArray.forEach(function (oSec) {
				if (oSec === oItem.getText()) {
					var oItemKey = oItem.getKey();
					aItemsArray.push(oItem);
				}
			});
		});

		aItemsArray.forEach(function (oTextItem) {
			mBindingParams.filters.push(
				new sap.ui.model.Filter(
					"carrid",
					sap.ui.model.FilterOperator.EQ,
					oTextItem.getKey()
				)
			);
		});

	},

Output:

Hope this helps someone who is googling this outline.

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x