Thursday, January 17, 2013

Ribbon menu missing on page load after customisation


After  Customisation in sharepoint pages ribbon menu missing on page load for perticular webpart.

            In sharepoint 2010, if you have more than one webpart on webpart page, the ribbon disappears because SharePoint doesn't know which web part to display ribbon for. This is by design because if you have a document library web part and list web part on the same page, the ribbons are obviously differ for the two and sharepoint needs to know which webpart to display the ribbon for.

To avoid the above problem use the following javascript.

<Script>
setTimeout(function()
{

var obj = document.getElementById("MSOZoneCell_WebPartWPQ3");
if(obj != null)
{

var obj1 = new Array()

obj1["target"] = obj

obj1 ["srcElement"] = obj

WpClick(obj1)
}
},2000)

</Script>

Overlay calendar items open in new window instead in Modal Popup

When you create overlay calendar view for combined 2 or 3 views especially for colour coded calendar, if you create event with category and click on it, it will open in popup which is by default function of SharePoint.
If you create event without category column value and click on it, it will open in new window. To remove the above problem use the below javascript.

<script src="/sites/CUEDemo/Code%20Library/jquery-1.8.3.min.js" type="text/javascript"></script>

<script type="text/javascript">
// load our function to the delayed load list
                _spBodyOnLoadFunctionNames.push('calendarEventLinkIntercept');

                // hook into the existing SharePoint calendar load function.
                function calendarEventLinkIntercept()
                {
                                if (SP.UI.ApplicationPages.CalendarNotify.$4a)
                                                {
                                                var OldCalendarNotify = SP.UI.ApplicationPages.CalendarNotify.$4a;
                                                SP.UI.ApplicationPages.CalendarNotify.$4a = function ()
                                                {
                                                OldCalendarNotify();
                                                bindEventClickHandler();
                                                }
                                                }
                                if (SP.UI.ApplicationPages.CalendarNotify.$4b)
                                                {
                                                var OldCalendarNotify = SP.UI.ApplicationPages.CalendarNotify.$4b;
                                                SP.UI.ApplicationPages.CalendarNotify.$4b =  function ()
                                                {
                                                OldCalendarNotify();
                                                bindEventClickHandler();

                                                } 
                                }
                  // future service pack change may go here!
                  // if (SP.UI.ApplicationPages.CalendarNotify.???)
                }

                function bindEventClickHandler()             {
                                $('.ms-acal-rootdiv a').click(function(){EditLink2(this,'WPQ2');return false;});
                }



</script>

Avoid Contributor user to edit home page in sharepoint 2012 Team site

This is contributor permission issue(sharepoint 2012 bug). Normally when you create Sharepoint 2012 team site, the home page by default create under "SitePages" library.

The contributor users on site can easily modify home page and change setting of webpart and layouts.
The key to that issue is in the description "customize Web Part Pages in document libraries ", and it's the "in document libraries " that's the problem. When a page is in a library, it is treated as a file or document. If the user has "contribute" or Edit permissions to the library storing the page then they have the right to edit the page.
In 2007 the home page (default.aspx) was stored outside of a library, so "contributors" did not have edit rights by default. In 2010 Team Sites the home page is stored in the SitePages library that inherits permissions from the site, and therefore contributors have edit rights.
The solution is to set custom permissions in the pages library. Just break inheritance and grant your team members View only rights and the Site Owners full control.

Happy Coding.......... :-)