I got this to work. It wasn't an annotations-file centric approach, though. Rather, it involved coding out both controllers for the source and target apps.
The source app is an OVP Fiori Elements app. I should note that my work was done in VS Code.
In the source app, I used doCustomNavigation, but not in the way it is ordinarily used. As follows:
doCustomNavigation: function (sCardId, oContext, oNavigationEntry) {
var oCustomNavigationEntry;
oOtherBl = "";
if(oContext.sPath != null) {
var oEntity = oContext && oContext.getProperty(oContext.sPath);
if(oEntity.tile.substring(0, 5) === "Other") {
oOtherBl = "X";
}
}
return oNavigationEntry;
},
Note: oOtherBl = variable for BOOLEAN of Other category being chosen. That is all.
I am interested in passing a string of titles (the top 5) to EXCLUDE if they choose the Other title line item. (If you would like my SQLScript AMDP code for calculating the Other category based on the top N categories of a given column in a table, please let me know. It is good code).
An array of the top 5, compiled into a string, is of course read in the onInit function of the OVP app controller.
To get the array, you of course instantiate the oData model and then do .READ.
getParameters passes the Titles to exclude (5 in my case), as follows:
var aCustomSelectionVariant = [];
if(oOtherBl === "X") {
var oTile = {
path: "tile",
operator: "EQ",
value1: sTiles,
value2: null,
sign: "I",
};
aCustomSelectionVariant.push(oTile);
}
return {
selectionVariant: aCustomSelectionVariant,
ignoreEmptyString: true
};
I also had of course this to call getParameters:
onCustomParams: function (sCustomParams) {
if (sCustomParams === "getParameters") {
return this.getParameters;
} else if (sCustomParams === "param2") {
return this.param2;
}
}
The receiving app is more tricky. In that controller, we did this:
onInit: function() {
oComponent = this.getOwnerComponent();
this.oRouter = oComponent.getRouter();
this.oRouter.attachRouteMatched(this.onRouteMatched, this);
},
onRouteMatched: function(oEvent) {
this.setNavigationParameters();
},
And this...
onAfterRendering: function() {
var oNavigationHandler = new sap.fe.navigation.NavigationHandler(this);
var oParseNavigationPromise = oNavigationHandler.parseNavigation();
oParseNavigationPromise.done(function(oAppData, oStartupParameters, sNavType) {
if(oStartupParameters.tile != null) {
sTarget = oStartupParameters.tile[0];
} else {
sTarget = "Header";
}
}.bind(this));
},
sTarget being a global var (Other or Header or the Title you want to filter on).
Handling the non-Other category was straightforward. But this is what was tricky for handling the Other category:
if(oFilter.substring(0, 5) === "Other") {
var aTiles = [];
aTiles = oFilter.slice(6).split(",");
var aRanges = [];
aTiles.forEach(myFunc);
function myFunc(item) {
aRanges.push({
exclude: true,
keyField: "App_Title",
operation: "EQ",
tokenText: "!(=" + item + ")",
value1: item,
value2: null
});
}
var oDefaultFilter = oSmartFilterTab.getFilterData();
oDefaultFilter.App_Title = {
items: [],
ranges: aRanges,
value: null
};
// Set the initial filter values using setFilterData
oSmartFilterTab.setFilterData(oDefaultFilter, true);
So if you're interested in navigating from an OTHER category and then filtering on it (which is something difficult to do, nobody has written about this) this code should be very helpful to you. Good luck.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.