2

I have created a custom list and with a column called Account, the column is a dropdown list and with following options

  • Hourly
  • Silver
  • Gold

I would like the options above to be bold and be certain colors displayed in the list

  • Hourly = Red
  • Silver = Silver
  • Gold = Gold

What formula should I use for this?

1

You can try the approach detailed in this blog post: http://www.idubbs.com/blog/2012/js-link-for-sharepoint-2013-web-partsa-quick-functional-primer/

To summarize it, you use JSLink to override the rendering of the field to the appearance you need. The blog post shows you how to use a progress bar, but it shouldn't take too much work to change it to display in different colors.

1

You can do this in a calculated field. You have your Account column you will use to select what it is in the dropdown on your forms. Then, you create a separate column to show on the list view for the display as the calculated field. Lets call it Account Display. Try this formula and see if it works for you. I do this same type of process with images too for priority indicators.

=IF(Account="Hourly"," <div style="color:red;">Hourly</div>",
IF(Account="Silver"," <div style="color:CCC2C2;">Silver</div>",
IF(Account="Gold"," <div style="color:D9A441;">Gold</div>")))))

Be sure to go into SharePoint Designer and add the disable-output-escaping="yes" to the xsl:value-of property of the xslt node for your column or it will not render. This will be on the view of the list like the AllItems.aspx and not the DispForm.aspx pages.

EDIT: The XSLT code block to look for:

<xsl:template name="FieldRef_Text_body.Account_x0020_Display" ddwrt:dvt_mode="body" match ="FieldRef[@Name='Account_x0020_Display']" mode="Text_body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:param name="thisNode" select="."/>
    <xsl:choose>
        <xsl:when test="@AutoHyperLink='TRUE'">
    <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping ="yes"/>
  </xsl:when>
        <xsl:otherwise>
    <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes"/>
  </xsl:otherwise>
    </xsl:choose>
</xsl:template>
1

You can try using conditional formatting.It is described in details here

You can also try using jquery. You have to add a script in Edit Page\Edit Webpart\Miscellaneous and add the script in the JS portion(see the above link to find the exact location and then use the following script)

Here is a sample of the script. Edit it as per your requirement:

    <script type="text/javascript"src="//ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function () {
    $Text = $("td.ms-cellstyle.ms-vb2:contains('Green')"); 
    $Text.parent().css("background-color","#01DF3A");
    $Text = $("td.ms-cellstyle.ms-vb2:contains('Gold')");
    $Text.parent().css("background-color", "#EAC117");
    $Text = $("td.ms-cellstyle.ms-vb2:contains('Red')");
    $Text.parent().css("background-color", "#E9967A");
        });
    </script>
0

The easiest way that I have been able to find to format columns in sharepoint lists is to use calculated columns. Whilst you can use JS and completely re-code your page, perhaps you're looking for a simple answer like me. I want something that is user friendly and utilises existing functionality for future users to be able to see what I've done.

  1. Create a calculated column
  2. paste the below code and replace all capitals with your own column and choices
  3. change the syling to suit your needs by replacing colours and maybe even removing the background style
  4. Make sure that you select number as your calculated column type
  5. Create your column!
  6. you may want to hide the column you are referencing so that this is now the visible column
=IF([LOOKUPCOLUMN]="CHOICE1",
"<div style="""&"color: white; background: green"&""">CHOICE1</div>",
IF([LOOKUPCOLUMN]="CHOICE2",
"<div style="""&"color: white; background: red"&""">CHOICE2</div>",
IF([LOOKUPCOLUMN]="CHOICE3",
"<div style="""&"color: white; background: orange"&""">CHOICE3</div>",""
))) 
0

I acvhieved this using below

="<DIV><img width='30px' height='auto' src='"&IF(Status<>"Under revision","/SiteAssets/ICON/ok_yes.png",if(Status<>"Current","/SiteAssets/ICON/emo_Current.png","/SiteAssets/ICON/emo_no.png"))&"'></DIV>"

enter image description here

In my case i had to show symbol based on the status of the item in document library.

So you can utilize the same, instead image use with style.

Hope it helps.

-1

You can use the JSLink to resolve this issue.Here you can find sample example.

https://code.msdn.microsoft.com/office/Client-side-rendering-code-0a786cdd/sourcecode?fileId=109730&pathId=1836828232

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.