This one will be quick – I promise…
A common requirement encountered when demonstrating and/or implementing OOB WSS/MOSS calendars is to disable and/or hide one or more of those ‘special’ fields that make up the ‘Event’ content type.
I call these ‘special’ fields as they can’t be modified through the Web UI and are tied to some special functionality when used in conjunction with the calendar list.
The solution proposed *should* be possible to implement through the Web UI as long as you have permissions to modify pages and you have either:
- Referenced a JQuery Library in your master page
- Have a copy of the JQuery library somewhere in your _Layouts directory you can reference
- Domain Policies and/or Corporate Firewalls will allow you to reference an externally hosted JQuery library
This solution has been developed under the assumption of the later. If none of these options are possible, I suppose the solution could be re-worked utilizing standard Javascript to achieve the same result.
Lets jump in…
Assuming the calendar you want to modify already exists, open the corresponding NewForm.aspx appending ‘?toolpanview=2’ to ht URL:
This will allow you to edit the form without detaching it from the list definition.
Add a Content Editor Web Part and position it below the form itself. Edit the source and provide the following:
<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
//Hide the ‘All Day Event’ Field:
//$("TABLE.ms-formtable>TBODY>TR:eq(5)").css('display', 'none');
//Hide the ‘Recurrence’ Field:
//$("TABLE.ms-formtable>TBODY>TR:eq(6)").css('display', 'none');
//Hide the ‘Workspace’ Field
$("TABLE.ms-formtable>TBODY>TR:eq(7)").css('display', 'none');
</script>
Couple of things to note here:
The first line is the reference to the external JQuery library as previously discussed. If you host a copy internally, change this to point to that. If your master page already references a JQuery library, omit it all together.
I have provided three lines of code in the secondary script block. (Two of which are commented out) These are explained inline above. Note that the JQuery hides rows of the form table based on index (defined by the final ‘:eq(n)’ JQuery selector clause). The indexes used above will hide the correct rows for an OOB ‘Event’ content type, but should be modified where this form has been modified through the addition of fields to the List or underlying content type.
Simply repeat the same step for the ‘EditForm.aspx’ Form and Bob’s your Mother or* Father’s Brother.
*replace with ‘and’ if your family is into that sort of stuff
The end result (for the code above with the hiding of the first two special fields being commented out) should look like:
Careful:
Note that while hiding the ‘All Day Event’ and ‘Recurrence’ fields through the Web UI will stop users from using this functionality when creating items using their browser, They options are still available to those users who have connected the calendar to their Outlook Client!
How do you add the content editor web part to the form page? I don't see the ability to add a web part to the page.
ReplyDeleteJoe, I am having the same problem.
Deletehttp://x.x.x.x.com/sites/MIC_SW/x/x/Lists/RandyCal/NewForm.aspx?toolpanview=2
I can add web parts to the calendar page, but once I am one the NewForm page (which is where the items are I want to hide) I am unable to add a content editor web part either. Using 2007 w/sp3.
Any extra insight to this would be appreciated.
thanks!
damn genius!
ReplyDeleteHi Joe, If you're using 2010 the option is in the ribbon if your using 2007 you need to add toolpaneview=2 to the url of the form you want to edit.
ReplyDeleteOf all the solutions I've found, my favourite!
ReplyDeleteGreat solution! I cannot seem to get it to work properly within my calendar. I'm using SharePoint 2010. I inserted your code into a CEWP and attached to the NewForm.aspx.
ReplyDeleteOptionally, if you never want it to show, you can edit the content type and set the value to hidden.
ReplyDeleteIn SPD, navigate to the list. Open the underlying content type (Event). Choose Edit columns. Select the column you want to hide. Then, select administration web page. It will give you the standard (Required, Optional, Hidden) selections for the selected column - including the otherwise unavailable three (All Day, Recurrence, Workspace).
This is an all or nothing deal. Once you hide the content type, it won't show up on any of the forms.
perfect. How did you find out about the existence of paneview?
ReplyDelete