0

I want to know is there out of box feature for SharePoint List to give the color. For Example -

I've one list column Completed and Pending. So here I want if status is Pending it should be Red or If Status is completed it should be Green. Is there any OOTB feature avilable in SharePoint.

Please advice

  • 1
    There is no out of the box way. You need to either use JSLink or jQuery/JavaScript – Amal Hashim Nov 4 '14 at 11:52
  • I don't have requirement for something hide/show or some other effect. What about SharePoint Designer. Is it helpful for only change the color column. – user3760253 Nov 4 '14 at 12:09
  • In case of SP 2010 you could use SharePoint Designer and conditional formatting as described here: blogs.msdn.com/b/balsharfi/archive/2011/10/20/… – pholpar Nov 4 '14 at 12:12
  • Just I changed in subject I'm using SharePoint 2013 so is it possible in this? – user3760253 Nov 4 '14 at 12:25
1

It depends on your definition of OOTB. JSLink is a feature available OOTB, but involves client-side scripting. If this falls within your realm of possibilities, here's a link explaining how to use JSLink.

What you need to do is:

  1. Create a JavaScript file and upload it to your master page gallery as a new JavaScript Display Template.
  2. Specify the Name, Title and Description.
  3. Set the Target Control Type to View and Standalone to Override.
  4. Set Target Scope to the url of the website this override applies to.
  5. Specify the template ID for your list under Target List Template ID. Here is a list of the template ID's, if you don't know them.
  6. Save and Publish the template.

Simply modify the list view web part where you want this effect, and enter the url to the file in the JSLink option (under Advanced, I believe).

The JavaScript file contents should be the following:

(function() {
    var statusFieldCtx = { };

    statusFieldCtx.Templates = { };
    statusFieldCtx.Templates.Fields = {
        Status: {
            View: StatusFieldViewTemplate
        }
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(
        statusFieldCtx
    );
})();

function StatusFieldViewTemplate(ctx) {
    var _statusValue = ctx.CurrentItem.Status;    // Status is the field.  Replace with whatever field you have.
    if (_statusValue === 'Completed') {
        return "<span style='background-color: green;'>" + _statusValue + "</span>";
    }
    if (_statusValue == 'In Progress') {
        return "<span style='background-color: yellow;'>" + _statusValue + "</span>";
    }
    return "<span style='background-color: red;'>" + _statusValue + "</span>";
}
  • Thanks Wjervis, So I think its possible only through coding there is not some functionality (without code) available in SharePoint 2013 / Designer to archive this..correct me if I'm wrong. – user3760253 Nov 4 '14 at 12:27
  • Code is required to achieve this functionality. – wjervis Nov 4 '14 at 12:58
0

Using OOTB tools: Create a new column of type Calculated and set the Formula as

="<span style='background-color: " & IF([Status]="Pending","red","green") & ";'>" & [Status] & "</span>"

"The data type returned from this formula is" select any other value than "Single line of text" to avoid HTML escaping.

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.