SharePoint 2010 Document Management: Document push

Source: Internet
Author: User
Tags current time object model

Document push function, not a complex function, we here simple application of Ribbon customization, JS use, object model push (server side), below, let us briefly introduce the document push function.

First, the function design:

Document push function, mainly is a document library, select several documents, click the Push menu on the Ribbon menu, jump into the push page, push the page to select the target list, click the Push button, and push the selected documents to the target document library.

I am here to copy the past, and did not choose to move, of course, if you need such a function, you can slightly modify to achieve the purpose. The push process may have a heavy life, so that I can push the file name plus the current time before the exception occurs.

Second, the source code structure

As shown in the figure above, includes a feature (used to activate the function), a visual webpart (push function), a Ribbon (menu).

Third, add Ribbon:

Add Ribbon menu should be a relatively simple function, create a ribbon empty element, add our Ribbon XML, write this XML. The function of this ribbon is to call a JS function, which is added to the page through the Content editor.

Of course, if you are not very familiar with the addition of ribbon, you can refer to the following reference documents, is about SharePoint2013 how to add ribbon, the process and SharePoint2010 version is the same, the document description is very clear, I believe you can easily complete this step.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="Ribbon.CustomGroup" RegistrationId="101" RegistrationType="List" Title="推送文档"
Location="CommandUI.Ribbon">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.Documents.New.Controls._children">
<Button Id="Ribbon.Documents.New.PushDocsButton"
Command="PushDocsButtonCommand"
Image32by32="/_layouts/2052/images/formatmap32x32.png"
LabelText="推送文档"
TemplateAlias="o2" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="PushDocsButtonCommand"
CommandAction="javascript:PushDoc()" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>

Four, prepare JS script:

The role of JS script is to go to the page to find, we select which items, and then the ID of the document into a string, used to send to push the page to use.

Of course, the JS script also transmits the GUID of the source list, in order to know we want to push the document from where, these are relatively easy to understand, because of writing JS script, there is no DW, SPD, such as the editor, is written in Notepad, the style is more ugly, we can do it. JS script attached:

<script>
function Jumpurl (TableID, Jumpurl, Listid) {
var stridcoll = "";
var obj_table = document.getElementById (TableID);
var obj_trcoll = Obj_table.getelementsbytagname ("tr");
for (var i = 0; i < obj_trcoll.length; i++) {
if (obj_trcoll[i].iid!= undefined) {
var obj_input = obj_trcoll[i].getelementsbytagname ("input");
if (Obj_input.length > 0) {
if (obj_input[0].checked) {
var striid = obj_trcoll[i].iid + "";
var intI1 = Striid.indexof (",") + 1;
var intI2 = Striid.lastindexof (",");
Striid = striid.substring (intI1, intI2);
Stridcoll + + (striid + "-");
}
}
}
} if (Stridcoll.length > 0) {
var url = jumpurl + "? Idc= "+ stridcoll.substring (0, stridcoll.length-1) +" &listid= "+ Listid;
window.open (URL);
}
else {
Alert ("Please select push document ...");
}
}
function Pushdoc () {
Jumpurl (' onetidDoclibViewTbl0 ', '/sitepages/docspush.aspx ', ' d0501c8e-e765-4206-85b1-553a559508f8 ');
}
</script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.