Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Why highlighted items not showing in search? [Javascript]

$
0
0

Hello Everyone !

       

I have a Javascript code that highlights my results on a specific status. The script works fine, but the problem when i search for an invoice id the color of the highlighted item disappear in search view.

So what should i add to the code to enable it in search view ?

This is my code:

<script type="text/javascript">     SPClientTemplates.TemplateManager.RegisterTemplateOverrides({         OnPostRender: function statusFieldContext(ctx) {        var rows = ctx.ListData.Row;
var color= "#FFFFFF";        for (var i=0;i<rows.length;i++)        {          var isApproved = rows[i]["Status"] == "Approved";          var isPending = rows[i]["Status"] == "Pending";          var isRejected = rows[i]["Status"] == "Rejected";          var isOpen = rows[i]["Status"] == "Open";          if (isApproved)          {            color = "#ada";          }
else if (isPending){
color = "DarkOrange";          }          else if (isRejected){              color = "#FF7474";          }          else if (isOpen){                color = "#AEF9F8";          }          var rowElementId = GenerateIIDForListItem(ctx, rows[i]);          var tr = document.getElementById(rowElementId);   if(tr != null){
tr.style.backgroundColor = color;  }           }      }     });    </script>


Take a look on these 2 pictures:

  [1]: https://i.stack.imgur.com/YPCzp.png  -- Before searching
  [2]: https://i.stack.imgur.com/HIxmg.png -- After searching

Thank you !

                           

Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>