Skip to Content

search is not working in sap ui5 table upon formatter and color used

HI Experts,

I have to get the search on the basis of two parameters. I am using formatter but not able to get the right search data in that. I am my sharing application code. Please check if you would have faced this issue before.

Issue : 1) If without any color only Approve/Rejetc present then it gives correct result.

2) If approve/reject with color then it gives wrong search result. Upon approve search it gives the approve as well as remove with yellow color text. It should return only approve or reject.

XML Code :<Text id="id" text="{parts :['key>available','key>available1'],formatter: '.formatter.applyparameter'}"
modelContextChange="updateStatusColor"></Text>

formatter :

applyparameter used to give the required status.

Controller code :applyparameter: function (available, available1) {
 if (available === "" && available1 === "Y") {

 return "Approve";
 } else if (available === "Y" && available1 === "Y") {
 return "Approve";
 } else if (available === "N" && available1 === "Y") {
 return "Approve";
 } else if (available === "Y" && available1 === "") {
 return "Approve";
 } else if (available === "" && available1 === "") {
 return "";
 } else if (available === "" && available1 === "N") {
 return "Reject";
 } else if (available === "N" && available1 === "N") {
 return "Reject";
 } else if (available === "Y" && available1 === "N") {
 return "Reject";
 } else {
 return "Reject";
 }
 }

onSearch: function (oEvent) {
var sQuery = oEvent.getSource().getValue();
 //var sQuery = oEvent.getParameter('query');
var oList = this.getView().byId("tabletcode3");
var oBinding = oList.getBinding("items");
 if (sQuery) {
var aFilter = [];
 aFilter.push(new Filter("available", FilterOperator.Contains, sQuery));
aFilter.push(new Filter("availabl1", FilterOperator.Contains, sQuery));
  oBinding.filter(new Filter({
 filters: aFilter,
 and: false
 }));
 } else {
 // Use empty filter to show all list items
 // oBinding.filter(new Filter([])); does not work
oBinding.filter([]);
 }
 }


updateStatusColor: function (oEvent) {
   if (oEvent.getSource().getId().search("id") !== -1) {
    if (oEvent.getSource().getBindingInfo("text").binding) {
     var aParam = oEvent.getSource().getBindingInfo("text").binding.getValue();
     if (aParam[0] === "" && aParam[1] === "Y") {
      oEvent.getSource().addStyleClass("yellow");
     } else if (aParam[0] === "Y" && aParam[1] === "Y") {
     } else if (aParam[0] === "N" && aParam[1] === "Y") {
      oEvent.getSource().addStyleClass("yellow");
     } else if (aParam[0] === "Y" && aParam[1] === "") {
     } else if (aParam[0] === "" && aParam[1] === "") {
     } else if (aParam[0] === "" && aParam[1] === "N") {
      oEvent.getSource().addStyleClass("yellow");
     } else if (aParam[0] === "N" && aParam[1] === "N") {
     } else if (aParam[0] === "Y" && aParam[1] === "N") {
      oEvent.getSource().addStyleClass("yellow");
     } else {
     }
    }
   }
  }

Add a comment
10|10000 characters needed characters exceeded

Related questions

0 Answers

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.