0

I am playing with Document Set in SharePoint where document set's documents takes default view. However, I dont want to show few columns (e.g. 'Status', 'Salary' etc.) in default view but want to show it in Document Set child view.

I was successful in hiding columns in default view with hideColumn(). However, showColumn() shows column one above another (Check the attach pic). Please suggest.

function hideColumn(pColumnDisplayName) {
    var header = document.querySelectorAll("[displayname='" + pColumnDisplayName + "']")[0].parentNode;
    var index = [].slice.call(header.parentNode.children).indexOf(header) + 1;
    header.style.display = "none";
    for (var i = 0, cells = document.querySelectorAll("td:nth-child(" + index + ")"); i < cells.length; i++) {
        cells[i].style.display = "none";
    }
}

function showColumn(pColumnDisplayName) {
    var header = document.querySelectorAll("[displayname='" + pColumnDisplayName + "']")[0].parentNode;
    var index = [].slice.call(header.parentNode.children).indexOf(header) + 1;
    header.style.display = "block";//block will show that column
    for (var i = 0, cells = document.querySelectorAll("td:nth-child(" + index + ")"); i < cells.length; i++) {
        cells[i].style.display = "block"; 
    }
}

enter image description here

  • Hi Chintan, have you tried Inline-Block? I believe that just block essentially forces the element to be in a column format rather than allowing them to be in a row format. – KGlasier Dec 24 '18 at 15:19

Your Answer

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

Browse other questions tagged or ask your own question.