Introduction
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.
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.
Code Step
<script language="javascript" src="/JS/jquery-1.9.0.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$('nobr:contains("Complete")').closest('tr').hide();
$('nobr:contains("Manager")').closest('tr').hide();
});</script>
Before
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. 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.
Summary
In this article introduce these hidden columns on your New and Edit forms but not your Disp form.