0

As an example, is there a way to use a managed metadata for languages spoken, but when viewing the list, the column would show a flag thumbnail instead of the text entry?

It looks like this is close, but I don't see how it could support multiple icons: Can I use a custom field type icon instead of value?

1

This is possible using JsLink. Suppose the Managed Metadata column has these terms

enter image description here

Save the flag images with the same name as terms somewhere in the library on in the layouts folder. A sample jslink code is below for list view.

CustomizeFieldRendering = function () {  
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
        Templates: {
            Fields: {
                'MM': {
                    'View':function(ctx) {
                      return "<img src='http://site_url/_layouts/15/images/"+ctx.CurrentItem.MM.Label+".png' width='50px'/>";
                    }
                }
            }
        }
    });
}; 

ExecuteOrDelayUntilScriptLoaded(CustomizeFieldRendering, 'clienttemplates.js');

and the output is

enter image description here

| improve this answer | |
  • Thanks, got me off to a good start, but how does this handle multiple terms? In this scenario, if an item had both the "Australia" & "New Zealand" terms, then the images don't work. I am seeing that it would change from ctx.CurrentItem.MM.Label -> ctx.CurrentItem.MM.Label[0], but I'm not sure how to do the multiple images. – Ryan Tollefson Oct 3 '17 at 19:03
  • Inside the 'View' function: code if (ctx.CurrentItem.MM[0]){ var mText = ""; for(i=0; i<ctx.CurrentItem.MM.length; i++){ mText = mText + "<img src='http://site_url/_layouts/15/images/"+ctx.CurrentItem.MM[i].Label+".png' width='50px'/>" } return mText; } – Ryan Tollefson Oct 3 '17 at 19:49
  • Sorry, I don't really understand code highlighting in comments for stackexchange yet... anyways, above comment should fix for multiple images & if there is an item without a metadata term(blank). – Ryan Tollefson Oct 3 '17 at 19:56

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.