Skip to Content
Jul 11, 2019 at 11:53 AM

Cannot sort a date field SmartTable using the class sap.ui.model.Sorter


Currently I have developed a UI5 app that shows a SmartTable with the data coming from the SAP API API_MANAGE_WORKFORCE_TIMESHEET.

What I am trying to do is via the date field TimeSheetDate, however this does not seem to work. When I am trying however to sort any other field numeric or string it appears to work.

Does anyone know why this is happening? Would I require to create a custom column for this to work?

In my controller, I am writing the following code:

onAfterRendering: function () {

var oSmartTable = this.getView().byId("table0");

var oTable = oSmartTable.getTable();

var items = this.getView().byId("table0").getTable().getBinding("items");

console.log(items); // eslint-disable-line no-console /

/table grouping

oTable.getBinding("items").sort(new sap.ui.model.Sorter("TimeSheetDate", true, true));

//oTable.getBinding("items").sort(new sap.ui.model.Sorter("PersonWorkAgreementExternalID", true, true));

Attached are a couple of screenshots highlighting the problem.

Can somebody help me with this issue I am facing?


sorter-works.png (54.1 kB)
sorting-fail.png (56.5 kB)