Hide specific columns from Newform.aspx and Editform.aspx page
Many a times you come across a requirement where users would like to hide a column from the Newform.aspx and Editform.aspx pages however would like to retain the columns for the SharePoint list/library. This is possible OOB. Here is how:
- Open Newform.aspx or Editform.aspx page in edit mode. You can find more info about how to this in my previous post.
-
Add a Content Editor Web Part on the page and add following javascript code to the source editor. You may change the column names in the code based on the names of the columns in the list/library you are working on.
<script language="javascript" type="text/javascript">_spBodyOnLoadFunctionNames.push("hideFields");function findacontrol(FieldName){var arr = document.getElementsByTagName("!");for (var i=0;i < arr.length; i++ ){if (arr[i].innerHTML.indexOf(FieldName) > 0){return arr[i];}}}function hideFields(){varcontrol = findacontrol("Column Name 1");control.parentNode.parentNode.style.display="none";control = findacontrol("Column Name 2");control.parentNode.parentNode.style.display="none";}</script>
I wanted to extend a word of thanks to my colleagues I work with - Rohan Chittyal, Nidhi Gupta and Amol Ghuge.
Advertisement




leave a comment