Skip to content

Commit 287bed3

Browse files
1 parent 3dc3b3e commit 287bed3

File tree

1 file changed

+77
-3
lines changed

1 file changed

+77
-3
lines changed

app/webapp/controller/App.controller.js

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,13 +1031,15 @@ sap.ui.define("z2ui5/UITableExt", ["sap/ui/core/Control"], (Control) => {
10311031
properties: {
10321032
tableId: {
10331033
type: "String"
1034-
}
1035-
}
1034+
},
1035+
},
10361036
},
10371037

10381038
init() {
10391039
z2ui5.onBeforeRoundtrip.push(this.readFilter.bind(this));
1040+
z2ui5.onBeforeRoundtrip.push(this.readSort.bind(this));
10401041
z2ui5.onAfterRoundtrip.push(this.setFilter.bind(this));
1042+
z2ui5.onAfterRoundtrip.push(this.setSort.bind(this));
10411043
},
10421044

10431045
readFilter() {
@@ -1055,12 +1057,84 @@ sap.ui.define("z2ui5/UITableExt", ["sap/ui/core/Control"], (Control) => {
10551057
let id = this.getProperty("tableId");
10561058
let oTable = z2ui5.oView.byId(id);
10571059
oTable.getBinding().filter(aFilters);
1060+
var opSymbols = {
1061+
EQ: "",
1062+
NE: "!",
1063+
LT: "<",
1064+
LE: "<=",
1065+
GT: ">",
1066+
GE: ">=",
1067+
BT: "...",
1068+
Contains: "*",
1069+
StartsWith: "^",
1070+
EndsWith: "$"
1071+
};
1072+
1073+
aFilters.forEach(function(oFilter) {
1074+
var sProperty = oFilter.sPath || oFilter.aFilters?.[0]?.sPath;
1075+
if (!sProperty) return;
1076+
1077+
oTable.getColumns().forEach(function(oCol) {
1078+
if (oCol.getFilterProperty && oCol.getFilterProperty() === sProperty) {
1079+
var operator = oFilter.sOperator;
1080+
var vValue = oFilter.oValue1 !== undefined ? oFilter.oValue1 : oFilter.oValue2;
1081+
1082+
if (vValue === undefined && oFilter.aFilters && oFilter.aFilters[0].oValue1 !== undefined) {
1083+
vValue = oFilter.aFilters[0].oValue1;
1084+
}
1085+
1086+
var display;
1087+
if (operator === "BT") {
1088+
var vValue2 = oFilter.oValue2 !== undefined ? oFilter.oValue2 : "";
1089+
display = (vValue != null ? vValue : "") + opSymbols["BT"] + (vValue2 != null ? vValue2 : "");
1090+
} else if (operator === "Contains") {
1091+
display = "*" + (vValue != null ? vValue : "") + "*";
1092+
} else if (operator === "StartsWith") {
1093+
display = "^" + (vValue != null ? vValue : "");
1094+
} else if (operator === "EndsWith") {
1095+
display = (vValue != null ? vValue : "") + "$";
1096+
} else {
1097+
display = (opSymbols[operator] || "") + (vValue != null ? vValue : "");
1098+
}
1099+
1100+
oCol.setFilterValue(display);
1101+
oCol.setFiltered(!!display);
1102+
}
1103+
});
1104+
});
1105+
10581106
}
10591107
, 100, this.aFilters);
10601108
} catch (e) { }
10611109
;
10621110
},
1063-
1111+
readSort() {
1112+
try {
1113+
let id = this.getProperty("tableId");
1114+
let oTable = z2ui5.oView.byId(id);
1115+
this.aSorters = oTable.getBinding().aSorters;
1116+
} catch (e) {}
1117+
},
1118+
1119+
setSort() {
1120+
try {
1121+
setTimeout((aSorters) => {
1122+
let id = this.getProperty("tableId");
1123+
let oTable = z2ui5.oView.byId(id);
1124+
oTable.getBinding().sort(aSorters);
1125+
1126+
aSorters.forEach(function(srt, idx) {
1127+
oTable.getColumns().forEach(function(oCol) {
1128+
if (oCol.getSortProperty && oCol.getSortProperty() === srt.sPath) {
1129+
oCol.setSorted(true);
1130+
oCol.setSortOrder(srt.bDescending ? "Descending" : "Ascending");
1131+
if (oCol.setSortIndex) oCol.setSortIndex(idx);
1132+
}
1133+
});
1134+
});
1135+
}, 100, this.aSorters);
1136+
} catch (e) {}
1137+
},
10641138
renderer(oRM, oControl) { }
10651139
});
10661140
}

0 commit comments

Comments
 (0)