0

I am looking to create some kind of status indicators for a list that I have produced. I just want a simple red, amber, green setup.

I came across the status indicator webpart but I couldn't get this to work with my list. I have had a look online and have read that this webpart has been discontinued in SharePoint Online (https://support.office.com/en-us/article/discontinued-features-and-modified-functionality-in-microsoft-sharepoint-2013-bbbb0815-2538-4f1d-b647-1f7f6d508c93?ui=en-us&rs=en-us&ad=us)?!

Does anyone know if this is the case and if so how would I go about making a simple status indicator on my list on SharePoint Online?

  • Let me see if I get the idea, you want to set a column that depending on a value , show green, yellow or red? – Marco Jan 11 '17 at 16:11
  • Yeah pretty much. Like a basic traffic light system show green for complete, amber for in progress and red for not started. Is that what can be done in status indicators? – James Jan 11 '17 at 16:16
0

Office-365 introduced a Client Rendering Mode (CSR) which represents a rendering engine for list views, list forms and search results. I would recommend you to consider that approach. Example and Article

CSR Example
Assume you have Priority column in the list with (high, normal or low) values. Save following file as .js extension and upload to your style library and link to list webaprt JsLink property.

(function () {
    // Initialize the variable that stores the objects.
    var overrideCtx = {};
    overrideCtx.Templates = {};

    overrideCtx.Templates.Fields = {
         'Priority': { 'View': priorityIndicatorFiledTemplate }
             };

    // Register the template overrides.
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);

})();

function priorityIndicatorFiledTemplate(ctx) { 
var _ProrityText = ctx.CurrentItem.Priority;


switch (_ProrityText.toLowerCase()) { 
        case "high": 
            return "<span style='color :#f00'><img src='/Style%20Library/Images/Red.png' width='10px' height='10px' /> " + _ProrityText+ "</span>"; 
            break; 
        case "normal": 
            return "<span style='color :#ff6a00'><img src='/Style%20Library/Images/Green.png' width='13px' height='13px' /> " + _ProrityText+ "</span>"; 
            break; 
        case "low": 
            return "<span style='color :#cab023'><img src='/Style%20Library/Images/Orange.png' width='10px' height='10px' /> " + _ProrityText+ "</span>"; 
    } 
}

RESULT

enter image description here

  • I'm new to Sharepoint and coding as well. I have a small question, with respect to the above code, how do I mention a column name if my Internal column name is different from my display column name? (Ex: In my custom list, the display column name is '2017_q1' and my internal column name is '_x0032_017_x0020_q1') – Parinita Hirehal Jan 18 '18 at 17:44
0

You can use the CSR (Client Side Rendering) technique. Create a .js file and add it as a JSLink to the webpart (View o Form). Here an example for a field called Status in a list view:

(function () {

    var statusFieldContext = {};
    statusFieldContext.Templates = {};
    statusFieldContext.Templates.Fields = {
        "Status": { "View": statusFieldTemplate }
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(statusFieldContext);

})();

function statusFieldTemplate(ctx) {

    var status = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];

    switch (status) {
        case "Completed":
            return "<span style='color :#008000'>" + status + "</span>";
            break;
        case "In Progress":
            return "<span style='color :#FDF5E6'>" + status + "</span>";
            break;
        case "Not Started":
            return "<span style='color :#FF0000'>" + status + "</span>";
    }
}

Here you can take a look on other examples and how to add the jslink to the webpart.

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.