@@ -1031,13 +1031,15 @@ sap.ui.define("z2ui5/UITableExt", ["sap/ui/core/Control"], (Control) => {
1031
1031
properties : {
1032
1032
tableId : {
1033
1033
type : "String"
1034
- }
1035
- }
1034
+ } ,
1035
+ } ,
1036
1036
} ,
1037
1037
1038
1038
init ( ) {
1039
1039
z2ui5 . onBeforeRoundtrip . push ( this . readFilter . bind ( this ) ) ;
1040
+ z2ui5 . onBeforeRoundtrip . push ( this . readSort . bind ( this ) ) ;
1040
1041
z2ui5 . onAfterRoundtrip . push ( this . setFilter . bind ( this ) ) ;
1042
+ z2ui5 . onAfterRoundtrip . push ( this . setSort . bind ( this ) ) ;
1041
1043
} ,
1042
1044
1043
1045
readFilter ( ) {
@@ -1055,12 +1057,84 @@ sap.ui.define("z2ui5/UITableExt", ["sap/ui/core/Control"], (Control) => {
1055
1057
let id = this . getProperty ( "tableId" ) ;
1056
1058
let oTable = z2ui5 . oView . byId ( id ) ;
1057
1059
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
+
1058
1106
}
1059
1107
, 100 , this . aFilters ) ;
1060
1108
} catch ( e ) { }
1061
1109
;
1062
1110
} ,
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
+ } ,
1064
1138
renderer ( oRM , oControl ) { }
1065
1139
} ) ;
1066
1140
}
0 commit comments