Thanks for your reply. I tried with below approach:
In my Master.cotroller.js. i have placed below code:
jQuery.sap.declare("sap.ui5.sflight.util.Grouper");
sap.ui.controller("sap.ui5.sflight.zui5_sflight_book.Master", {
handleGroup : function(evt) {
// compute sorters
var sorters = [];
var item = evt.getParameter("selectedItem");
var key = (item) ? item.getKey() : null;
if ("Year" === key) {
var grouper = sap.ui5.sflight.util.Grouper[key]; (##### here is the issue)
sorters.push(new sap.ui.model.Sorter(key, true, grouper));
}
// update binding
var list = this.getView().byId("list");
var oBinding = list.getBinding("items");
oBinding.sort(sorters);
},
});
In my master.view.xml the concerned call is:
<footer>
<Bar>
<contentRight>
<Select id="groupSelect" change="handleGroup" icon="sap-icon://group-2"
type="IconOnly" selectedKey="None" autoAdjustWidth="true">
<core:Item key="None" text="None" />
<core:Item key="Year" text="Year" />
<!-- <core:Item key="Year1" text="Year1" /> -->
</Select>
</contentRight>
</Bar>
</footer>
so the "key" is Year which I am passing to my grouper.js. Now the grouper.js content is as below:
jQuery.sap.declare("sap.ui5.sflight.util.Grouper");
sap.ui5.sflight.util.Grouper = {
bundle : null, // somebody has to set this
Year : function(oContext) {
var Year = oContext.getProperty("Year");
var key = null, text = null;
if (Year = 2015) {
key = "Y15";
text = "Year 2015 ";
} else if (Year = 2016) {
key = "Y16";
text = "Year 2016 ";
}
return {
key : key,
text : text
};
}
}
But system is not able to find the grouper.js as it is not getting loaded. Please advice how to solve this issue.
Thanks, SL