Quantcast
Channel: Microsoft Online: SharePoint Online forum
Viewing all articles
Browse latest Browse all 10096

Colour formatting on one web part

$
0
0

Hi everyone

I am creating a page which has 3 web parts, each of these web parts show three different views of the same custom list.  I want to apply conditional formatting on one of these web parts but I can't get it to work.  The basic structure of the code is below:

    SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function () {

        SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
            OnPostRender: function (ctx) {
		
        $Text = $("td .ms-vb2:contains('No')").filter(function() {

  return $(this).text() == "No";})

        $Text.css("background-color", "#e1f7d5");

In the past I would have used an if statement such as if (ctx.ListTitle == "List Name" so the formatting is only applied to the web part for that list.  However I can't do that this time as all three web parts are displaying the same list.  I've tried using an if statement checking ctx.viewTitle and ctx.WPQ but these don't seem to work as the formatting doesn't apply to any of the web parts when I add these.

I'd be grateful for any advice anyone has on how I can get this to work.

Thanks for your help in advance.


Viewing all articles
Browse latest Browse all 10096

Trending Articles



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