You all know that you can send a copy of a document from one document library to another by using the dropdown on the “Name” column and selecting “Send to > Other location”.
Some of you also know that you can add a predefined “send to location” under Document library settings > Advanced settings.
The irritating fact is that you can only add one custom location here.
Here is a method for setting this custom send to location by javascript – and being able to manipulate it for each view – or by a dropdown select.
To set the location for a view – put this code in a CEWP
below the list view:
1 | <script type= "text/javascript" src= "../../Javascript/jquery-1.3.2.min.js" ></script> |
2 | <script type= "text/javascript" > |
4 | ctx.SendToLocationName = "My custom send to location" ; |
6 | ctx.SendToLocationUrl = ctx.HttpRoot + "/TestLibrary" ; |
To have a dropdown select, use this code:
01 | <script type= "text/javascript" src= "../../Javascript/jquery-1.3.2.min.js" ></script> |
02 | <script type= "text/javascript" > |
04 | var mySendToArr = [ '<select location>|' , |
10 | var mySelect = $( "<select id='myCustomSendToSelector'></select>" ); |
11 | $.each(mySendToArr, function (idx,item){ |
12 | var split = item.split( '|' ); |
13 | var opt = $( "<option></option>" ); |
20 | $( "#onetidPageTitle" ).append( "<div style='font-size:10px;float:right;margin-top:-15px' id='insertMySendToSelectHere'>Send to location: </div>" ); |
21 | $( "#insertMySendToSelectHere" ).append(mySelect); |
24 | $( "#myCustomSendToSelector" ).change( function (){ |
25 | var SendToLocationName = $( this ).find( 'option:selected' ).text(); |
26 | var SendToLocationUrl = $( this ).find( 'option:selected' ).val(); |
27 | if (SendToLocationUrl!= '' ){ |
28 | ctx.SendToLocationName = SendToLocationName; |
29 | ctx.SendToLocationUrl = SendToLocationUrl; |
31 | ctx.SendToLocationName = "" ; |
32 | ctx.SendToLocationUrl = "" ; |
This script adds a dropdown above the view selector like this
More info at
http://sharepointjavascript.wordpress.com/2010/02/17/manipulating-the-custom-send-to-destination-in-document-library-with-javascript/
No comments:
Post a Comment