javascript - Filter on Formatted value and not on Model binding -
we have sap.m.table , in 1 column value formatted , shown in ui. so, lets assume data coming backend : "eventdatetime":"2017-04-05t12:32:35.276z".
we receive time zone such timestamp.
now, convert received data using time zone , show data in : 06:32 04/04/2017 format.
now, need apply column filter table. can see there difference in backend value , value shown on screen ( data visible day behind due time zone conversion). now, apply filter on formatted value shown in ui rather value present in ui.
so have basic filter date :
new sap.ui.model.filter({ path: spath, operator: "bt", value1: avalue[1], value2: avalue[2] })
consider dummy data :
{ "root":[ { "eventdatetime":"2017-03-14t17:04:22.856-05:00", "createdatetime":"2017-03-10t19:38:11-05:00", "waybillid":827xxxx330697, "waybillserialnumber":60xx4277, "killreason":"empty", "killdatetime":"2017-03-29t22:20:00-05:00", "waybillnumber":2xx71, "serviceorderdatetime":"2017-03-10t19:38:00-05:00", "eventtimezone":"est", "createdatetimezone":"est" }, { { "eventdatetime":"2017-04-14t17:04:22.856-05:00", "createdatetime":"2017-03-10t19:38:11-05:00", "waybillid":82784xxx0697, "waybillserialnumber":6033xxx4277, "killreason":"empty", "killdatetime":"2017-03-29t22:20:00-05:00", "waybillnumber":2xx2071, "serviceorderdatetime":"2017-03-10t19:38:00-05:00", "eventtimezone":"mdt", "createdatetimezone":"ist" } } ] }
please help.
you need pass test
function filter, returning true
or false
according condition:
new sap.ui.model.filter({ path: spath, test: function(value){ // value actual value cell return value === yourcondition; //here check value against condition } });
edit: filtering multiple conditions
new sap.ui.model.filter({filters: [ new sap.ui.model.filter({ path: spath, test: function (value) { // value actual value cell return value === squery; //here check value against condition } }), new sap.ui.model.filter({ path: spath2, //same or different path test: function (value) { return secondcheck(value); //different condition } }) ], and: true //set false "or" behaviour })
edit 2: passing root element spath
new sap.ui.model.filter({ path: "", //instead of matching "{eventdatetime}" bind entire object test: function(value){ return isequal(value.eventdatetime, value.eventtimezone); } });
documentation: https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.ui.model.filter.html
Comments
Post a Comment