I have a document library in SP2013 that is full of forms. My users get confused by the "Check Out Required" box that pops up when they open the file. I keep telling them they need to download a copy, but this seems to be an issue. So, I looked into adding a "Download a Copy" button or link to the library, and came up with this solution, which is put in a snippet on a Web Part Page (source: https://amalhashim.wordpress.com/2013/11/29/sharepoint-2013-document-library-download-a-copy-button/):
<script type="text/javascript">
function runAfterEverythingElse(){
var elementArray = document.getElementsByClassName("ms-vb-lastCell");
var idArray = document.getElementsByClassName("ms-listlink");
for(var i = 0; i < elementArray.length; i++)
{
elementArray[i].innerHTML = '<a unselectable="on" href="javascript:;" onclick="window.open(\''+ idArray[i]['href'] + '\')" class="ms-cui-ctl-large " aria-describedby="Ribbon.Documents.Copies.Download_ToolTip" mscui:controltype="Button" role="button" id="Ribbon.Documents.Copies.Download-Large"><span unselectable="on" class="ms-cui-ctl-largeIconContainer"><span unselectable="on" class=" ms-cui-img-32by32 ms-cui-img-cont-float"><img unselectable="on" alt="" src="/_layouts/15/1033/images/formatmap32x32.png?rev=31" style="top: -409px; left: -35px;"></span></span><span unselectable="on" class="ms-cui-ctl-largelabel">Download a<br>Copy</span></a>';
}
}
_spBodyOnLoadFunctionNames.push("runAfterEverythingElse");
This partially works, in that it puts a button next to each document that says "Download a copy," but the action is actually just open the file in Word (instead of in the browser). The check-out prompt is still there, so I know it's opening the file and not downloading a copy. So while I like the way it looks, but the functionality isn't right.
In the answers to another question here (How to trigger a file download when clicking an html button or javascript), I found some instructions, but I can't figure out how to use them. I tried creating a workflow that created a download link and put it in an html-formatted field, but can't get the formatting right.
I don't really care if the solution is library-based (a field on each document probably created through Nintex Workflow) or Web Part Page based (script/snippet). I'm not fluent with jquery, javascript, or other programming languages. I know HTML, and can fumble my way through with CSS, but I'm pretty much a straight copy-paste from the internet solution kind of girl. I am not a programmer, just the person who manages our SharePoint site alongside may other job functions. :)
Any advice on how to tweak the original code or how to do this better is greatly appreciated. We're using SP2013.
#Kelly I implemented this solution in sharepoint 2010 using Dataview webpart.
Dataview webparts loops through all the documents in doc library and below code allow user to download the file.
Test.docx - Download a copy
I hope it helps. :)
Related
I have a pdf file stored at some location on my server. On click of a link I want to add a text-watermark to this pdf file and then print it.
something like this:
in aspx say we have a (button a link-button or a simple link)
<a id="abc" href="../test.pdf" onclick="watermarkAndPrintPdf()"> PrintPdf </a>
or
<asp:linkbutton id="abc" runat="server" onclick="watermarkAndPrintPdf()" Text="Print Pdf"/>
Now when user click this link my code should add watermark(which will probably the loged-in user name) and print this document.
I want to know what ['watermarkAndPrintPdf()'] this function will be.......
Note:-It is a web application in C# asp.net 4.0.
(I don't mind if print dialog box opens or It prints without it.)
Please help....
would suggest taking a look at PDFsharp it's an open source dll for producing pdf's through code, there are a number of examples of producing a watermark on this page of the PDFsharp website:
http://www.pdfsharp.com/PDFsharp/index.php?option=com_content&task=view&id=40&Itemid=51
If you need any help using it I am more than willing to lend a hand as I have used this package to produce pdf's in the past.
hope this helps.
Can you give me here some code by which I can click on anchor label on a webpage. I want click on the "Configuration"label. These labels are used to navigate from one page to another page. Here is some part of the Web page view source.
<td class="tabtext-unsel"><nobr>Catalogs</nobr></td>
<td class="tabtext-sel"><nobr>Configuration</nobr></td>
After some discussion in comments i can suggest another answer:
Automation and Scripting Language
You may use this to navigate complicated pages, automate work in any application etc. It can copy almost any data and paste it to excel for example.
Maybe this will help you:
Youtube: MrExcel's Learn Excel #665 - Scraping Webpages
There is a technique called web scraping.
You may find many tutorials about web scraping, there are some tutorials for excel.
I want to create tool tips for each part in a form which employees have to fill in a share point web page. When users move the mouse cursor on each field (Title, description, department etc.) the related tip will be automatically became visible as a simple pop-up (tool tip) and summarize what they should write there. and when the mouse cursor is not on one of these fields there is no tool tip.
How can I design such a system via share point designer? I am not able use any add ons. I can't upload any additional things to the server. I have to make page based design.
I would be glad if you kindly help me.
Have you considered using field description?
This is SharePoint's default way of adding additional information to fields.
I couldn't find the ToolTip control in my SharePoint Designer 2007 Toolbox, so I looked on W3Schools.com for a standard HTML option and found that you can use the <ABBR> tag.
See http://www.w3schools.com/tags/tag_abbr.asp for the reference, but here's an example of a tooltip implemented on a SharePoint field title in a display form:
<td valign="top" class="ms-formlabel" style="width: 50px">
<H3 class="ms-standardheader">
<nobr><abbr title="The actual number of man-days effort expended.">Man-days (Actual)</abbr></nobr>
</H3>
</td>
Open up the aspx page for the form in SharePoint designer. Then you can use SharePoint designer just like Visual Studio to see the code. Try adding the "tooltip" attribute to the field controls within the form. There is a small possibility these controls will actually be written using XSLT instead of ASP, so be prepared to do some studying.
By default the display name of the site column becomes the tool tip for that field.
I have a search box web part. In that web part I have created an instance of SearchBoxEx like
SearchBoxEx par=new SearchBoxEx
par.goImageUrl=""
par.DropDownMode= DropDownModes.DisplayScopeDD;
Button sear= new Button();
sear.Click += new EventHnadler(sear_Click);
I have added a button to that search Box web part.Now I have to read the scope selected in the SearchBoxEx in the sear_Click event.Can anyone please guide me in the right direction
Any help would be really appreciated.
You could read the Request.QueryString["s"] parameter, even when it is a post, the SearchBoxEx adds it.
Edit
Based on the comments and new info, are you using 'pure' javascript? This would be a jquery example:Search
WARNING: You should change the site masterpage INSIDE your site with SharePoint designer, not the one in the C:\Program Files\etc... folder. You could also navigate to the http://yourportal/_catalogs/masterpage library and download a copy of the default.master to change it then upload it back to the library, do all this carefully, you can break your sharepoint very easily.
Insert above the </HEAD> tag in your masterpage:
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
function newSearchResultsPageWithScope()
{
var scope = $(".ms-sbscopes select").val();
location.href = "/CustomResultsPage.aspx?s=" + scope;
}
</script>
The jquery portion is pretty straightforward, it gets the <td> with the class="ms-sbscopes", and the <select> element under it, then it sets the 'scope' variable to the selected value of the scopes dropdown.
Also, customizing the masterpage in a sharepoint site is fine, do not worry with that.
When a list item has an attachment, SharePoint automatically renders a paperclip image for that particular row, which indicates that the item has an attachment. Is there any way to change the image that is rendered?
The site is in a shared hosting environment, so I can't simply replace the image on the file system. Also, there are other lists that are part of the same site that should use the default image.
Is there any way to change the image that is rendered for items with an attachment on an individual list basis?
EDIT: Following is the HTML that is rendered:
<td class="ms-vb2">
<img align="absbottom" src="http://devsandbox/_layouts/images/attach.gif" alt="Attachment"/>
</td>
The only real way you'll be able to do this is to use jQuery (or some other javascript library). You'll need to locate the elements you want to update on the page and change the URL's
$('img[src*=attach.gif]').each(function() {
$(this).attr('src', '/path/to/new/image.png');
}
My jQuery may be a touch wrong but that should be near enough to give you an idea of what to do
Edit - The best way to have this down would be via a custom WebPart which renders the JavaScript. This way it can easily be dropped into any page you want
i don't know which element off the top, but I would look for it in one of the stylesheets and use SharePoint designer to do the replacement work for a specific list.
Use Firebug to inspect the element that you want to revert. This will tell you the css class and other properties used by that element. Then write your own class and add it to the core.css file or if you want, add it to the css for the Site/Site Collection through the MasterPages link in Site Settings.
EDIT
I used firebug to look at an image in SharePoint and here is how it is rendering.
<img id="img_1-2_" class="rpo-gif rpo-gif-2" border="0" style="padding: 0px;" alt="Expand/Collapse" src="/_layouts/images/minus.gif"/>
As you can see it is using a class and setting a src to '/_layouts/images/minus.gif'. Well you can go find that file in the 12Hive directory and then replace it with an image of your choice that has the same name.