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 !