Survey Purpose:
We use
surveys to ask team members what they think about issues, how to improve your
processes, and many other topics. You can collect the results by using several
different types of questions, such as multiple choice, fill-in fields, and even
ratings.
Problem Description:
How to
hide "Respond to this Survey" when a user has already responded to
the Survey
It’s simple
but little bit tricky to implement as it involves user controls also.
Imp point to note:
·
The
Rendering Template for the Survey List is in the defaulttemplates.ascx
Control
under 12/Template/Control template.
·
The
rendering template ID is ‘ViewToolBar. This template renders the "Respond
to
this Survey", Actions menu and Settings menu in the toolbar.
·
This
template is a generic template which is used by other lists as well.
·
"Respond
to this Survey" is rendered by <SharePoint:NewMenu
AccessKey="<%$Resources:wss,tb_NewMenu_AK%>"
runat="server" />.
How exactly it looks like:
<SharePoint:RenderingTemplate ID="ViewToolBar" runat="server">
<Template>
<wssuc:ToolBar CssClass="ms-menutoolbar" EnableViewState="false" id="toolBarTbl"
ButtonSeparator="<img src='/_layouts/images/blank.gif' alt=''>"
RightButtonSeparator=" " runat="server">
<Template_Buttons>
<SharePoint:NewMenu
AccessKey="<%$Resources:wss,tb_NewMenu_AK%>" runat="server" />
<SharePoint:ActionsMenu
AccessKey="<%$Resources:wss,tb_ActionsMenu_AK%>" runat="server" />
<SharePoint:SettingsMenu
AccessKey="<%$Resources:wss,tb_SettingsMenu_AK%>" runat="server" />
</Template_Buttons>
<Template_RightButtons>
<SharePoint:PagingButton runat="server"/>
<SharePoint:ListViewSelector runat="server"/>
</Template_RightButtons>
</wssuc:ToolBar>
</Template>
</SharePoint:RenderingTemplate>
<Template>
<wssuc:ToolBar CssClass="ms-menutoolbar" EnableViewState="false" id="toolBarTbl"
ButtonSeparator="<img src='/_layouts/images/blank.gif' alt=''>"
RightButtonSeparator=" " runat="server">
<Template_Buttons>
<SharePoint:NewMenu
AccessKey="<%$Resources:wss,tb_NewMenu_AK%>" runat="server" />
<SharePoint:ActionsMenu
AccessKey="<%$Resources:wss,tb_ActionsMenu_AK%>" runat="server" />
<SharePoint:SettingsMenu
AccessKey="<%$Resources:wss,tb_SettingsMenu_AK%>" runat="server" />
</Template_Buttons>
<Template_RightButtons>
<SharePoint:PagingButton runat="server"/>
<SharePoint:ListViewSelector runat="server"/>
</Template_RightButtons>
</wssuc:ToolBar>
</Template>
</SharePoint:RenderingTemplate>
Microsoft Recommendation:
1.
We
cannot modify OOB defaulttemplates.ascx as this would be unsupported
2.
Make
a copy of defaulttemplates.ascx under CONTROL TEMPLATES FOLDER of 12 hive
and rename it to CustomDefaultTemplates.ascx
and rename it to CustomDefaultTemplates.ascx
What exactly
needs to done/Resolution:
1. To hide “Respond to this Survey” if a
user has already responded to the survey,
Create a class which inherits from the Microsoft.Sharepoint.WebControls.NewMenu.
Create a class which inherits from the Microsoft.Sharepoint.WebControls.NewMenu.
2. In this override CreateChildControls
and have your logic to hide unhide "Respond
to this Survey" based on your need.
to this Survey" based on your need.
3. Build the class library and install
the dll to the GAC.
4. Modify the “ViewToolBar” in the
custom ascx such that to render your custom
"Respond to this Survey" menu from the class library you created.
"Respond to this Survey" menu from the class library you created.
(Note: You need to add your assembly reference and register the tag prefix in the
Custom ascx control.)
5. Next step is to render the custom
rendering template to the "Survey List" so
that the custom "Respond to this Survey" menu will be rendered
in the toolbar.
6. For this the
"ToolbarTemplate" property of the View should be changed in the
schema.xml file of the Survey List
definition.
7. As modifying the OOB files are not
supported, Copy the “SurveyList” folder from
12/Template/Features and paste in the
same place as “CustomSurveysList”.
Change the feature ID of the
“CustomSurveyList”
8. Open the schema.xml file available under
survey folder of “CustomSurveysList”
and add the
“ToolbarTemplate=CustomViewToolBar” attribute to the “View BaseID=0”.
Example attached:
<View
BaseViewID="0" FreeForm="TRUE" ReadOnly="TRUE" Type="HTML"
ToolBarTemplate=" CustomViewToolBar ">
9. Install and activate
"CustomSurveysList"
10. Create a Survey List using
CustomSurveyList template and we should be able to
achieve the functionality as
required.
If you have any queries/questions regarding the above mentioned information
then please let me know, Thank you.
No comments:
Post a Comment