Link to home
Start Free TrialLog in
Avatar of vdhavala
vdhavala

asked on

Disabeling clicking on items in a SharePoint Document library

Hello,

I have a document library that has several word documents in it. Whenever the user clicks on an item, it opens the document. Also, there is a little down arrow at the end of each item that displays the View Properties, Edit Properties, Edit in Microsoft Office Word etc.

My question is, is there a way I can prevent the user from directly clicking on the item to open the document?  I want to force them to use the down arrow to use the  "Edit in Microsoft Office Word" option?

Please suggest.

Thanks in Advance.
Avatar of raybies
raybies
Flag of Australia image

Not really. The closest you can get is....

1.- Modify the All Document view or Create a new default 1.
2.- Uncheck "Name (linked to document with edit menu) "
3.- Check "Edit (link to edit item)" and "Title"
4.- Order as required

You could create a dataview with the appropriate call to the javascript function "DispEx()"
Avatar of vdhavala
vdhavala

ASKER

But this will not help me open the document in Microsoft Office word. Edit (link to edit item) will open the properties of the document to modify but does not open the document as such.
ASKER CERTIFIED SOLUTION
Avatar of raybies
raybies
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot for the code.. But if you dont mind, how and where do I put the code?

I just have access to add a document library and add items in it in our SP Site. I am confused as to where I should put this code and the steps. Can you please help me?

Thanks again !
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It did not work for me. I'm very sure I must have done something wrong. This is what I did..
My document library's name is "System Test Summary Report"

I renamed the [YOUR_LIST_NAME] with System Test Summary Report (I left the double quotes as it is).
Then I named the file as disableclick.aspx
Then I put it in the Forms directory of the document library. I dont have a web directory in my doc library.

Is this correct?

My file is attached in the code snippet. And also, below are the names of the documents that I have in my Forms directory.

Document (this is a folder)
WebFldr.aspx
AllItems.aspx
Combine.aspx
DispForm.aspx
EditForm.aspx
repair.aspx
Upload.aspx

<%@ Page language="C#" MasterPageFile="~masterurl/default.master"    Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
 
 
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">	
	
	
	<WebPartPages:DataFormWebPart runat="server" IsIncluded="True" FrameType="None" NoDefaultStyle="TRUE" ViewFlag="0" Title="System Test Summary Report" ListName="System Test Summary Report" Default="FALSE" DisplayName="System Test Summary Report" __markuptype="vsattributemarkup" __WebPartId="{A1296B0F-CEAF-4E1C-ABF2-8B77840A5D6D}" id="g_a1296b0f_ceaf_4e1c_abf2_8b77840a5d6d">
		<DataSources>
				<SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;/View&gt;" id="System Test Summary Report">
						<SelectParameters>
								<WebPartPages:DataFormParameter Name="ListName" ParameterKey="ListName" PropertyName="ParameterValues" DefaultValue="System Test Summary Report"/>
						</SelectParameters>
				</SharePoint:SPDataSource>
		</DataSources>
		<ParameterBindings>
				<ParameterBinding Name="ListName" Location="None" DefaultValue="System Test Summary Report"/>
				<ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
				<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
				<ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
		</ParameterBindings>
		<datafields>@FileLeafRef,Name (for use in forms);@FileDirRef,Path;</datafields>
		<XSL>
				<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
						<xsl:output method="html" indent="no"/>
						<xsl:decimal-format NaN=""/>
						<xsl:param name="dvt_apos">'</xsl:param>
						<xsl:variable name="dvt_1_automode">0</xsl:variable>
						<xsl:template match="/">
								<xsl:call-template name="dvt_1"/>
						</xsl:template>
						<xsl:template name="dvt_1">
								<xsl:variable name="dvt_StyleName">Table</xsl:variable>
								<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
								<table border="0" width="100%" cellpadding="2" cellspacing="0">
										<tr valign="top">
												<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
														<th class="ms-vh" width="1%" nowrap="nowrap"/>
												</xsl:if>
												<th class="ms-vh" nowrap="">URL Path</th>
										</tr>
										<xsl:call-template name="dvt_1.body">
												<xsl:with-param name="Rows" select="$Rows"/>
										</xsl:call-template>
								</table>
						</xsl:template>
						<xsl:template name="dvt_1.body">
								<xsl:param name="Rows"/>
								<xsl:for-each select="$Rows">
										<xsl:call-template name="dvt_1.rowview"/>
								</xsl:for-each>
						</xsl:template>
						<xsl:template name="dvt_1.rowview">
								<tr>
										<td class="ms-vb" style="height: 24px">
												<A onfocus="OnLink(this)" href="{@FileRef}" onclick="DispDocItemEx(this,'FALSE','FALSE','TRUE','SharePoint.OpenDocuments.2')">
													<xsl:value-of select="@FileLeafRef" />
												</A>
										</td>
								</tr>
						</xsl:template>
				</xsl:stylesheet>
		</XSL>
	</WebPartPages:DataFormWebPart>
		
</asp:Content>

Open in new window

1.- U don't need to put it in to the "Forms" folder, but it works in there too.
2.- Try again with the below... it's the same except line

13: <SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="<View></View>" id="SystemTestSummaryReport">


 id="SystemTestSummaryReport" without the spaces.

<%@ Page language="C#" MasterPageFile="~masterurl/default.master"    Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
 
 
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">	
	
	
	<WebPartPages:DataFormWebPart runat="server" IsIncluded="True" FrameType="None" NoDefaultStyle="TRUE" ViewFlag="0" Title="System Test Summary Report" ListName="System Test Summary Report" Default="FALSE" DisplayName="System Test Summary Report" __markuptype="vsattributemarkup" __WebPartId="{A1296B0F-CEAF-4E1C-ABF2-8B77840A5D6D}" id="g_a1296b0f_ceaf_4e1c_abf2_8b77840a5d6d">
		<DataSources>
				<SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;/View&gt;" id="SystemTestSummaryReport">
						<SelectParameters>
								<WebPartPages:DataFormParameter Name="ListName" ParameterKey="ListName" PropertyName="ParameterValues" DefaultValue="System Test Summary Report"/>
						</SelectParameters>
				</SharePoint:SPDataSource>
		</DataSources>
		<ParameterBindings>
				<ParameterBinding Name="ListName" Location="None" DefaultValue="System Test Summary Report"/>
				<ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
				<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
				<ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
		</ParameterBindings>
		<datafields>@FileLeafRef,Name (for use in forms);@FileDirRef,Path;</datafields>
		<XSL>
				<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
						<xsl:output method="html" indent="no"/>
						<xsl:decimal-format NaN=""/>
						<xsl:param name="dvt_apos">'</xsl:param>
						<xsl:variable name="dvt_1_automode">0</xsl:variable>
						<xsl:template match="/">
								<xsl:call-template name="dvt_1"/>
						</xsl:template>
						<xsl:template name="dvt_1">
								<xsl:variable name="dvt_StyleName">Table</xsl:variable>
								<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
								<table border="0" width="100%" cellpadding="2" cellspacing="0">
										<tr valign="top">
												<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
														<th class="ms-vh" width="1%" nowrap="nowrap"/>
												</xsl:if>
												<th class="ms-vh" nowrap="">URL Path</th>
										</tr>
										<xsl:call-template name="dvt_1.body">
												<xsl:with-param name="Rows" select="$Rows"/>
										</xsl:call-template>
								</table>
						</xsl:template>
						<xsl:template name="dvt_1.body">
								<xsl:param name="Rows"/>
								<xsl:for-each select="$Rows">
										<xsl:call-template name="dvt_1.rowview"/>
								</xsl:for-each>
						</xsl:template>
						<xsl:template name="dvt_1.rowview">
								<tr>
										<td class="ms-vb" style="height: 24px">
												<A onfocus="OnLink(this)" href="{@FileRef}" onclick="DispDocItemEx(this,'FALSE','FALSE','TRUE','SharePoint.OpenDocuments.2')">
													<xsl:value-of select="@FileLeafRef" />
												</A>
										</td>
								</tr>
						</xsl:template>
				</xsl:stylesheet>
		</XSL>
	</WebPartPages:DataFormWebPart>
		
</asp:Content>

Open in new window

It did not work for me. I pasted the new code in Disableclick.aspx and pasted it in the Forms directory. However, I am still able to click on the item and it opens...

Is there anything wrong that I am doing?
Can I name it Disableclick.aspx ? Or does it have to be someother name of aspx that is already there in the directory? Like DispForm.aspx ? How will SharePoint know that it needs to refer to the new aspx file ?


Show me a screen shot
Your not giving me anything to work with.

YOU NEED to point your browser @ http://YOURSITE/System%20Test%20Summary%20Report/Forms/disableClick.aspx

The page should render all the document links, and when u click on 1 it should open the document.
Oh ok...I'm really sorry. I am pretty new to this stuff and am struggling.

My web browser points to the link
https://iABC/XYX/tnc/gbs/System%20Test%20Summary%20Report/Forms/AllItems.aspx

So I renamed my AllItems.aspx to AllItems_old.aspx and renamed my Disableclick.aspx to AllItems.aspx so that the browser refers to the new aspx file.

When I try to open, I get an error;

An error occurred during the processing of /tnc/gbs/System%20Test%20Summary%20Report/Forms/AllItems.aspx. Unexpected end of file looking for </asp:Content> tag.


Is this the correct way of doing it? I am sorry if I am not getting it right. And I really appreciate you help and patience !

Thanks a ton in Advance.
Go back up to Reply ID:23504315.... MAKE SURE you copy ALL the code, start again. You're missing the closing </asp:Content> tag.

But in all honesty, since you've had such a hard time with this exercise, it's going to be A REAL STRUGGLE for you putting in the paging, and other columns.
OK..I tried and this is how my screen looks now (attached is the screen shot).

Is it quite difficult to achieve this functionaity? Please can you help me? This is quite critical. My save functionality does not work when the users click on the document directly. It however works fine when they do an edit and use the Edit in Microsoft Office option. Thats the main reason why I am struggling.
Like I said, I have not done SP programming. All I did is create document libraries and add documents and change the library settings if required.

Please Advice.
new-All-documets-view.bmp
However, even with this, I am able to click on the document (bb.doc). It does not disable the functionality. Does it work for you ?
I've given you the solution. The link mimics exactly the functionality of  "Context Menu" > Edit in Microsoft Office Word.

Is it quite difficult to achieve this functionaity?  For you yes, very.

Please can you help me? I've already given you the solution, if you want me to do your work then my rate is US$60/hr and you need to give me your exact requirements.

OK. I understand what you are saying. Thanks for all your time and help. You have been very patient.