Wednesday, September 9, 2009
SharePoint - Hide Custom List Fields
From time to time you will need to hide fields on a custom list form page (NewForm.aspx, DisplayForm.aspx, or EditForm.aspx) This can be accomplished by using a Content Editor Web Part and so Javascript as show above.
In order to add a CEWP to the Custom List Form page, go to your list and click on the New button. You will see in the address bar that the address is 'http://sitename/list/listname/NewForm.aspx, add ?toolpaneview=2 on the end so that your url looks like this: 'http://sitename/list/listname/NewForm.aspx?toolpaneview=2
This will bring you to the edit mode of the page. Add a CEWP and the javascript as shown above. In the "hideFields" function replace the variable of "Title" with the display name of the field you wish to hide. If you have a requirement where you need to hide more than one field, simply copy the lines and paste the line as shown below:
function hideFields() {
var control = findacontrol("Title");
control.parentNode.parentNode.style.display="none";
control = findacontrol("Next Field to Hide");
control.parentNode.parentNode.style.display="none";
}
And there you have it, hiding fields on a custom list form page.
Note: Make sure the fields you are hiding are not required*
Hope this helps!!
Sam
SharePoint - Hide Quick Launch
In some cases you may need to hide the quick launch on a single page without effecting your entire site, masterpages, etc... Since in-line css is referenced last when the site is rendered, this can be accomplished using a content editor web part (CEWP) and a little css.
To do this simply do the following:
To do this simply do the following:
- Add a CEWP to your page
- Open the Modify Shared Web Part Tool Pane
- Click on the Source Editor Button
- Add the following CSS
Click Save and you should now see that the Quick Launch is hidden.
Hope this helps!!
Sam
Subscribe to:
Posts (Atom)