Hiding columns in SharePoint is nothing new really, there have been several articles written on this topic. The approach for doing this, however, does inspire some debate in terms of what the best practice is. Let’s say we can agree that there are three ways to get this done:
- Using the built in content types to specify which columns you wish to be hidden.
- Using jQuery and a content editor web part to hide the columns as desired.
- Hide the columns programmatically using code.
I just wanted to make some comments on all three. The content type approach is a good one and relatively simple to implement. Once you’ve enabled content types for your list or library, click on the default content type, let’s say it’s Item, and choose the column you’d like to have hidden and simply set it’s column settings to Hidden. Here is an excellent reference for this technique: http://littletalk.wordpress.com/2009/03/30/hide-remove-title-column-from-sharepoint-list/.
Ok so the above works good, but what happens if you only want to introduce these hidden columns on your New and Edit forms but not your Disp form as an example. Or what if your scenario requires that they are hidden from all default New, Edit and Disp forms, but you have some custom SharePoint Designer disp forms that you’ve created that those fields need to be visible on. The content type approach will hide the column for all forms and so that won’t always work. We need something more granular.
So there is where the jQuery approach comes in handy. Some great resources for this:
- Paul Galvin has written some great articles on this topic over at EndUserSharePoint – http://www.endusersharepoint.com/2009/06/17/quick-and-easy-use-jquery-to-hide-a-text-field-on-a-sharepoint-form/ and http://www.endusersharepoint.com/2009/06/18/quick-and-easy-a-better-way-to-use-jquery-to-hide-a-text-field-on-a-sharepoint-form/
As per the comments by Nathan Ahlstrom in the second link noted above, the final fix for me was to use:
<script type="text/javascript"> $(document).ready(function() { $('nobr:contains("Completion time")').closest('tr').hide(); $('nobr:contains("Score")').closest('tr').hide(); }); </script>
Please note that I had to add quotes around the tr tag for this to work for me.
The final approach uses some custom code and the object model to hide columns for a given list. http://www.sharepointkings.com/2008/05/how-to-hide-column-of-sharepoint-list.html. Now I’m not entirely sure how this works with custom forms besides the New, Edit and Disp forms, and until I have time to try out, I won’t know the answer to that. It’s worth mentioning because it does give you some granularity in that you can specify hidden properties per form.
That’s all for now. Please send in your comments if you have them, would love to hear from you.





[...] Hide Columns in SharePoint New, Edit and Disp Forms [...]
Great post! I was looking for something like this…thanks
Where must this code be placed on NewForm.aspx, like under what tags?
Will this work in SharePoint 2010?
Hi Etienne,
I’m working on a follow up post right now that will describe this in more detail. This will work with 2010 but there is a better way, I’ll document that as well.
Any luck with this Shereen?
Hi Etienne,
Ok so I had thought you were asking something a little different, but now that I read this post again, you’re simply asking where in the NewForm.aspx you need to place your code? For this example, I’ve placed it just above:
Can you give that a try and let me know if it works?
I have SharePoint 2007. I do not have access to the server, but I am the site owner. I have a field “Priority Justification” in my change request list – but I want that field to be hidden until/unless the priority changes to something higher than “normal.” Any ideas?
Hi Jerry,
Have you looked up any jQuery solutions that might assist? So do you want to hide the column for just the new, edit and disp forms, or also within the views?
By using jQuery, I am able to hide fields in the “new” and “edit” forms. But, the script is not working for the display form. The script is getting executed, but the fields do not get hidden. Any solution here?
Hi Manjiri,
Can you send me the source code for the dispform (if that’s permitted)? It’s likely going to be because the way in which we’re attempting to locate the element is not working. In the mean time, I can try to see if this is reproducible on my end. shereen at qumsieh dot ca.
Hi Shereen,
I have a custom edit form where I am trying to use jQuery to enable\disable fields based on the current login. Where exactly do I put my jQuery code in my custom form? I use SPD for customization. Appreciate any response.
Hi Madhu,
If you are using SharePoint Designer, you have a couple of options:
1. Using Design view, you can add a content editor web part to the page, and then insert the jQuery code within the content editor.
2. You can insert the logic directly into the custom editform.aspx page within the PlaceHolderAdditionalPageHead content placeholder. Are you already linking the jQuery library in your master page? If not, you’ll have to include a link to the jQuery library above the script tag as well. Alternatively you could put the javascript in an external file and link to it from within your page. Does that help?
Hi All
I wanted to hide a meta data called content type in my EditpageForm.aspx.
I pasted this code in the Content Editor web part.But this is not working how will my jquery get called??
$(document).ready(function() {
$(‘nobr:contains(“Content type”)’).closest(‘tr’).hide();
});
My requirement is in the link below
http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010general/thread/2a15a8b3-bb78-459b-85a6-6412f6398647
Hi Ashik,
Do you have jquery included in your page?