on 01-16-2018 4:06 PM
Hi All,
I am facing one challenge while grouping the Samrttable data with date fields. The date is not coming in a formatted way(highlighted in yellow) and the grouping functionality is also not working properly(Sorting of the date is working fine).
Please let me know if there is a way to handle Grouping based on Date via annotation or with any other property and also the date formatting while showing in grouping section.
Best Regards,
Amit
Issue is solved by adding custom grouping function in BeforeRebind event for date columns.
var oSorter = mBindingParams.sorter[0];
//Check if sorter is for Grouping
if (oSorter && oSorter.vGroup) {
var boolGroupApplied = false,
groupObject;
//Replace the Grouping sorter itself
var aCustomColumns = [{
column: "ExtendTo",
text: this.getView().getModel("i18n").getResourceBundle().getText("ALV_table_Extend_Date"),
formatter: "dd.MM.yyyy"
}, {
column: "StartDate",
text: this.getView().getModel("i18n").getResourceBundle().getText("MOTH_Due_Date"),
formatter: "dd.MM.yyyy"
}, {
column: "ConstraintStartDate",
text: this.getView().getModel("i18n").getResourceBundle().getText("MOTH_Earliest_Start"),
formatter: "dd.MM.yyyy"
}, {
column: "ConstraintFinDate",
text: this.getView().getModel("i18n").getResourceBundle().getText("MOTH_Latest_Start"),
formatter: "dd.MM.yyyy"
}];
aCustomColumns.forEach(function (value, key) {
if (value.column === oSorter.sPath) {
boolGroupApplied = true;
groupObject = value;
}
});
if (boolGroupApplied) {
//Replace the Group function
// oSorter.fnGroup = this.mGroupFunctions();
mBindingParams.sorter[0] = new sap.ui.model.Sorter(oSorter.sPath, oSorter.bDescending, function (t1) {
var u1 = t1.getProperty(oSorter.sPath),
o1 = groupObject.text;
var oDateFormat = sap.ui.core.format.DateFormat.getDateInstance({
UTC: true,
pattern: groupObject.formatter
});
u1 = oDateFormat.format(u1);
if (u1 === undefined || u1 === null) {
u1 = "";
}
return {
key: u1,
text: o1 ? o1 + ": " + u1 : u1
};
});
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.