on 2017 Aug 09 2:20 PM
Hallo,
I am working on a use case where I have to group the column entries based on a group category and sort the entries with in the group.
I am using sap.ui.Table control. Since, the column group is based on custom criteria I have implemented custom sort with grouping on the data binding using model sorter.
I have followed the following post as an example and adapted it to my case -
https://blogs.sap.com/2013/11/29/custom-sorter-and-grouper/
Here is my implementation:
var mGroupInfo = {
I: { order: 1, text: "Incidents" },
N: { order: 2, text: "Notifications" }
}
var fGroup = function(value) { // Must group the values starts with 9 and 1
return utilities.startsWith(value,"9") ? "I" : "N";
}
var fnGrouper = function(oContext) {
var value = oContext.getProperty(sColBindingPath);
var group = fGroup(value);
return {
key: group,
text: mGroupInfo[group].text
};
};
var oSorter = new sap.ui.model.Sorter(sColBindingPath,false,fnGrouper);
oSorter.fnCompare = function(a,b) {
var agroup = mGroupInfo[fGroup(a)].order;
var bgroup = mGroupInfo[fGroup(b)].order;
if (agroup < bgroup) return -1;
if (agroup > bgroup) return 1;
// Sort with in the group if (a < b) return -1;
if (a == b) return 0; if (a > b) return 1;
};
this.getId("workorder-table").getBinding("rows").sort(oSorter);
Result:
The entries are sorted correctly according to the group but I do not see the group header text (like "Incidents" for entries start with 9 and "Notifications" for entries start with 1). For this to happen, the grouper function should go through. But while debugging I see that this function is not invoked at all.
Could some one please provide some hints what am missing here !! Thank you.
Request clarification before answering.
Check if these threads, give you some hint on the missing piece of code:
https://openui5beta.hana.ondemand.com/1.36.2/docs/guide/c4b2a32bb72f483faa173e890e48d812.html
http://www.saplearners.com/grouping-filtering-and-sorting-in-sap-m-table/
Regards,
Sharath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
77 | |
30 | |
8 | |
8 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.