I have this code to creates a list view like display the list column as a table. Now I see all the menu bar is deactivated (like edit item, view item, view history and everyone).

I want to enable this menu bar but I don't understand the code

    "use strict";

(function (ns) {
    ns.itemHtml = function (ctx) {
        var returnHtml = "";
        ctx.ListSchema.Field.forEach(function (element, index, array) {

            var label = element.DisplayName;
            var value = ""

            if (element.FieldType.toLowerCase() == "taxonomyfieldtype") {
                if (!ctx.CurrentItem[element.RealFieldName]) {
                    value = "";
                else {
                    value = ctx.CurrentItem[element.RealFieldName].Label
            else if (element.FieldType.toLowerCase() == "taxonomyfieldtypemulti") {
                if (!ctx.CurrentItem[element.RealFieldName]) {
                    value = "";
                else {
                    for (var i = 0; i < ctx.CurrentItem[element.RealFieldName].length; i++) {
                        value = value + ctx.CurrentItem[element.RealFieldName][i].Label + ";";
            else {
                value = getDefaultFieldHtml(ctx, element, ctx.CurrentItem, ctx.ListSchema);

            if (typeof value === 'undefined') {
                value = "";

            returnHtml += "<tr><td width='20%' class='ms-stylelabel'>" + label + "</td><td width='80%' class='ms-stylebody'>" + value + "</td></tr>";

        return returnHtml;

(function () {
    var overrides = {};
    overrides.Templates = {};

    overrides.Templates.Header = "<table class='ms-listviewtable' width='100%' id='MetadataView'>";
    overrides.Templates.Item = metadtaView.itemHtml;
    overrides.Templates.Footer = "</table>";


can somone explain what is going on in the code ?.


This is JSLink-- specifically JSLink bound to the webpart view. It looks like the table is just showing the managed metadata column field and it's contents for each list item. JSLink can completely take over the entire view/webpart.

It sounds like you may want to change where the JSLink is bound, so it can show the ECB instead of replacing the entire view. Check this and this out for more about JSLink.

| improve this answer | |
  • Yes i have checked the link before. The problem the page is rendered as a table and sharepoint is not recognising as a element because its a displayed simply as table using javascript. can i add this code function hideEdit() { var edit = document.getElementById("Ribbon.ListForm.Display.ManageGroup"); edit.style.display = "true"; } _spBodyOnLoadFunctionNames.push("hideEdit"); – user1514428 Sep 11 '17 at 11:47
  • In this list there will be always only one list item. Is it possible to set this item selected always so that the Ribbon is activated in the xsltview. – user1514428 Sep 11 '17 at 14:48

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.