Posts

Enabling a Button on the Ribbon Based on Selection

Image
Enabling a Button on the Ribbon Based on Selection A lot of people have asked me how to create a button which enables if and only if a single item is selected. This isn’t something we have out of the box, but the code to get this functionality is pretty simple. I’m going to assume that you’re generally familiar with SharePoint, CustomActions, and customizing the Ribbon – if that’s not the case, you’d probably be better off researching those things before delving into this. Basically, the enabling behavior all boils down to the following few lines of code: EnabledScript = " javascript:function singleEnable() {   var items =     SP.ListOperation.Selection.getSelectedItems();   var ci = CountDictionary(items);   return (ci == 1); } singleEnable(); " What this does is query to get the dictionary of selected items, and if the size of the dictionary is 1 it returns true (enable), otherwise it will return false (disable). Technically,

How To Hide Ribbon From Users Without Edit Page Privilege

 A way to remove or hide the ribbon area from user with lease privilege, and here is how: 1)       Open your SharePoint master page 2)       Locate this line: < div id ="s4-ribbonrow" class ="s4-pr s4-ribbonrowhidetitle"> 3)       Change it to: < div id ="s4-ribbonrow" class ="s4-pr s4-ribbonrowhidetitle" style =" display :none" > 4)       Now find the end of the “ s4-ribbonrow ” tag and add following block right after it: < Sharepoint : SPSecurityTrimmedControl ID ="SPSecurityTrimmedControl2" runat ="server" PermissionsString ="AddAndCustomizePages">     < script type ="text/javascript">         document.getElementById( "s4-ribbonrow" ).style.display = "block" ;     </ script > </ Sharepoint : SPSecurityTrimmedControl > 5)       Save the new master page and publish it. Learn more about SPSecurityTrimmedControl

How to Remove Corrupted SharePoint Sites – Preparing for SharePoint 2010 Upgrade

  SP2 had a number of enhancements designed around making it easier to upgrade to SharePoint 2010.  One such new feature that wasn’t popularized is your ability to find and remove corrupted, broken sites known as orphans. As I’ve mentioned in the past, with SharePoint being split across multiple databases, it is quite possible that a site could be in either the content database OR the config database. With service pack 2 there’s a new way to find orphaned sites.  In addition to running STSADM –o PreUpgradeCheck , one of my favorite tools along with TEST-SPContentDatabase with SharePoint 2010 you can identify these messed up corrupted sites. You’ll run enumallwebs (STSADM reference on TechNet) to identify the orphaned sites, and use deletesite (STSADM reference on TechNet) to remove them.  Note this command is available in SP2, and was enhanced in the post SP2 October Cumulative update.  You really should consider that October update as the most significant release with

Display List In Content Query Webpart

      <DIV id="ListPlaceholder"><IMG src="/_layouts/images/GEARS_AN.GIF"></DIV>       <!-- Paste the URL of the source list below: -->     <iframe id="SourceList" style="display:none;" src="/site/Lists/Calendar/Current%20Month%20Events.aspx" onload="DisplayThisList()"></iframe>       <script type="text/javascript">     function DisplayThisList()     {         var placeholder = document.getElementById("ListPlaceholder");         var displaylist = null;         var sourcelist = document.getElementById("SourceList");         try {                if(sourcelist.contentDocument)                   // Firefox, Opera                   {                 displaylist = sourcelist.contentDocument.getElementById("WebPartWPQ2") ;             }                else if(sourcelist.contentWindow)                   // Internet Explorer                   {            

Show or Hide SharePoint 2010 ribbon based on SharePoint Groups

This SharePoint 2010 solution allow site administrator to define who can or cannot see the SharePoint ribbon. In few words With this solution you can on each site define if the ribbon is display or not for :     * Everyone     * Anonymous user     * for one or many specific SharePoint groups This solution can be found on codeplex.com

Useful JavaScript global variables in SharePoint

If you’re using custom JavaScripts with SharePoint 2010 some global JavaScript variables may come in handy. These variables work if you’re using SharePoint’s default or any other custom master page.  L_Menu_BaseUrl – the base URL of the site / subsite. Very useful when you need to determine the absolute path of the site in JavaScript. Example: document.location = L_Menu_BaseUrl + ‘lists/calendar/allitems.aspx’ //redirects to Calendar list  L_Menu_LCID – the LCID of the site you’re in. Useful if you need to determine the language of the site. The list of Locale IDs can be found here .   _spUserId – the ID of the logged in user.

Hide Recently Modified Items

Image
Hide Recently Modified Items In SharePoint 2010 we all are familiar with the following annoying quicklaunch menu:   Follow these steps :  Go to  " Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\DocumentTemplates" . Open "wkpstd.aspx" file . Search for tag " SharePoint:RecentChangesMenu". Add visible="false"  at the end of this tag. Save this file & refresh SharePoint site .

Create the Edit Control Block Menu Item

  The solution that you create in this walkthrough creates a list item context menu entry for Microsoft Word .docx files. When users open the document context menu for a given .docx file, they can click the new entry to initiate the conversion of the document. To modify the ECB menu, you create a new feature and then add a new context menu item. To create a feature      1.In the Solution Explorer, right-click Features, and then click Add Feature.    2.Type a title for the feature; for example, Convert Document.    3.Type a description for the feature; for example, This feature converts Word Open XML documents by using Word Automation Services.    4.Accept the Web default feature scope, which gives the SharePoint Server 2010 farm administrators the ability to enable or disable the feature on a per-site basis.   After you create the feature, add the new context menu item. To add a context menu item      1.In the Solution Explorer, right-click the project, point to Add, and then

Add Solution / Deploy Solution

Hi, If you want to install a wsp file in SharePoint, you can use these script to install : Command # 1 : This command will add the solution in SharePoint ( Reference ) "%CommonProgramFiles%\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o addsolution -filename C:\Gaurav\SPSolution.TaskListRollup.wsp Command # 2 : This command will deploy the solution in SharePoint ( Reference ) "%CommonProgramFiles%\Microsoft Shared\web server extensions\14\BIN\stsadm.exe" -o deploysolution -name SPSolution. TaskListRollup .wsp -local -allowgacdeployment –allcontenturls Enjoy !

Hide Web Part Headers with SharePoint 2010

Hide a web part header in SharePoint 2010. 1.  Add a content editor web part to your page. 2. Edit the Web Part 3. Click in the content area of the web part, click HTML and select “Edit HTML Source” 4. Put the following code in the web part:    <style>       TR.ms-viewheadertr > TH.ms-vh2 {       DISPLAY: none       }    </style> 5. Click “OK” 6. Expand “Appearance” (on the right side of the page) 7. Set the chrome type to “None” 8. Click “OK” and then save and check in your page. The headers of your web part should now be hidden.  This can be extremely helpful when your page contains a web part using “boxed” for your style when creating a list view.  The only downside to this approach is if you have multiple web parts on a single page, it will hide the headers for all the web parts on your site.