Hiding SharePoint list column from list view

This article is about a JavaScript snippet that hides a specific column from a SharePoint list view. If I google this subject, most of the articles found on the Internet is about hiding a specific column from new, display or edit form. Although Javascript can do this, you can do the same thing without use of JavaScript by enabling list content-type as well. See here.

Not many articles talks about hiding columns from the list view though. (This one is an exception)
The link above shows the solution for toggling the particular columns. I only needed to hide a column from the list. But why do I even want to do that when one can simply create a view without that specific column you don’t want to see?
The reason is that I want to show the list based on filtered value from the column in question. I can add the filter webpart that I can connect to the target list, then specify the column to which the filter webpart will be connected to. In another word, for the filter to work, the column need to be a part of the list view (This is no longer the case with SharePoint 2013 or SharePoint online.  See below). Since the column will always show the same value for all displayed items(filtered value) I want to hide this column. If your company allows the use of SharePoint Designer, then you can use the Dataview webpart where you can use the column that is not shown to filter the items list. But Dataview creation and editing requires SPD. I wanted a easier solution, hence this javascript snippet.

if (typeof jQuery === 'undefined') { throw new Error('hide column snippet requires jQuery') }

//This function gets targetTable object and columnindex to hide
//targetTable is a jQuery object with single element.
function doHideColumn(targetTable,col) {
    targetTable.find(".ms-viewheadertr >*[class^='ms-v']").eq(col).hide();
    targetTable.find(" >tbody >tr").each(function(){$(this).find(">td:eq("+col+")").hide();});
$(function() {//this hide the colName column from all table in the page
    var    colName="colToHide";
    var    tarray=$("tr.ms-viewheadertr th:contains('"+ colName +"')");
    var    tlength=tarray.length;
    var    colindex;
    for (var i=0; i<tlength; i++) {
        doHideColumn($(tarray[i]).closest('.ms-listviewtable'), colindex);


This code snippet requires jQuery. You can use content editor Web Parts (CEWP) to include this code (don’t forget to wrap the code with script tag.) It works with SP2007 (My office’s current version) I may need to look at the code again when our IT upgrades the server to either 2013 or O365.  *Edit*  On SharePoint 2013 and SharePoint online filter can be applied to any list column regardless of if the target liist view contains the filtered column.  Therefore, solution explained here is unnecessary. *end Edit *
The code above scans the entire page for column headers with “colToHide” name and hide the column. (or columns if there are multiple lists in the page and if they contains the column with same name)
Since this code uses jQuery array object to hold the column information, it wont be difficult to modify the code to accept more than one column names to hide multiple columns from single list. For now, this snippet achieves what I need.

Filter Web parts are nice. For instance, URL query web parts let me create a page that contents are based on the filtered value in url query. For instance,
both link goes to the same page but the first link will show project phase 1 list items where the next link will show project phase 3 list.

2 thoughts on “Hiding SharePoint list column from list view

  1. Hi. Could you help me with something similar to this posting? I have an icon column that I display on a list. Based on different information in the item, I change the icon for that item. The heading over this column is redundant, as it simply says “Icon”.

    Is there an easy way to leave the column displayed in the list, but hide the heading text over the column?


  2. The code hide the column in two steps.
    1) hide the header with this code.

        targetTable.find(".ms-viewheadertr >*[class^='ms-v']").eq(col).hide();

    2) hide the column data with this code.

        targetTable.find(" >tbody >tr").each(function(){$(this).find(">td:eq("+col+")").hide();});

    Therefore if you omit the second line, then only the header will be hidden and not the column data.
    However, I think if you do that, then the header columns will shift by one from the column you hide and will not align correctly. Instead of using .hide(), you can try .text(”) so that the first line should read

        targetTable.find(".ms-viewheadertr >*[class^='ms-v']").eq(col).text('');

    Basically, you are replacing the column header text with blank string.

    I have not tested this solution (don’t have access to SP2007 right now) but I think this should work.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.