Context menu items in the SharePoint Document Library

Source: Internet
Author: User
Requirement Overview
SPS provides some default menus when you browse the documentation library on the SPS documentation library website. The default menu provided by the system can basically meet the general needs, but sometimes you need to add your own menu items.


Default menu

Custom menu

Menu item click Effect

Implementation Principle
In the ows. js file on the server side, we can see the following:CodeSegment

Function adddoclibmenuitems (M, CTX)

{

If (typeof (custom_adddoclibmenuitems )! = "Undefined ")

{

If (custom_adddoclibmenuitems (M, CTX ))

Return;

}

 
// Others

Custom_adddoclibmenuitems (M, CTX) is the interface provided by SPS for us.

Details
(1) edit a script to be added to the client.

<Script language = "JavaScript">

Function custom_adddoclibmenuitems (M, CTX)

{

VaR strdisplaytext = "watch a movie together at night, OK? "; // Display text of the menu item

VaR straction = "alert ('No, don't want to go with you! ') "; // The actual function of the menu item

VaR strimagepath = ""; // display image of the menu item

 

// Add the menu item to the context menu

Camopt (M, strdisplaytext, straction, strimagepath );

 

// Add a separator bar

Camsep (m );

 

// If true, the default menu item is not displayed.
// If it is fasle, the default menu item is displayed.

Return true;

}

</SCRIPT>

(2) Add the custom Javascript script to the page
Browse to the document library website that needs to be added to the custom menu
"Modify shared web page" => "add Web parts" => "Browse"
Drag "content edit web parts" to the page
Select modify shared Web parts"
In "layout", remove the "display on web page" check box
Click the "source editor..." button to add the completed export cirpt script to the dialog box and save it.
Now, click the context menu of the document library file to view only the menu items you have added.

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.