Saturday, September 10, 2016

SharePoint 2013 - To hide ribbon menus from SharePoint Pages


Sometime its annoying to have ribbon control which exposes all the menu ( new item, settings, etc to have it on all the list view pages). In order to hide Item menu and control some sections from List view from ribbon, I used below style sheet. We can use other many to hide as we want. Some how we have to use the \ behind  . for using this on style sheets as below


/*For to hide designer section*/
#Ribbon\.List\.CustomizeList {
display: none !important;
}

/*For to hide items section*/
#Ribbon\.ListItem-title {
display: none !important;
}
/*For to hide setting section*/
#Ribbon\.List\.Settings{
display: none !important;
}
/*For to hide list view section*/
#Ribbon\.List\.ViewFormat{
display: none !important;
}

/*For to hide page section*/
#Ribbon\.WikiPageTab-title{
display: none !important;
}



Happy Browsing!
Relax..

Thursday, August 25, 2016

SharePoint 2013 - Horizontal Breadcrum for Navigation


To get the breadcrum in the SharePoint 2013, use the below scripts.  
The navigation comes like - "Site Name > Sub Site name > Page Name " and etc.

Step 1: Please take a backup of masterpage that you currently have and create a copy. ( Directly working on the master page is a bit risk)
Step 2: Place the below code in the master page 
(anywhere - above toplink bar, above  content placeholder, or in the suite bar)
<SharePoint:AjaxDelta ID="deltabreadcrumbnav" runat="server"> <div id="breadcrumbnavigation"> <span class="breadcrumb-nav"> <asp:ContentPlaceHolder ID="ContentPlaceHolder" runat="server" > <asp:SiteMapPath SiteMapProvider="SPContentMapProvider" id="ContentMap" SkipLinkText="" runat="server"/> </asp:ContentPlaceHolder> </span> </div> </SharePoint:AjaxDelta>

Step 3: Save the file and upload in the master page gallery and publish the master page
Step 4: Try this new master page in a sub site ( to avoid any mess)  - Go to setting set the new master page as default. 
Step 5: Navigation should be up and running with default titles. 


Happy Browsing!
Relax..

Article Source: Microsoft Forum

Thursday, June 23, 2016

SharePoint 2013/2010 OTB Model Dialog Pop Up Window

To open a page in a pop up window, try this simple script.

Add the below script in the page your are good to go or add this in your master page and pass the parameter to this function to utilize this from any page or webpart.


< script type="text/javascript">
function OpenDialog(){        
var options = {            
url:'http://pageurlcomeshere',            
width: 500,            
height: 300 };          
SP.UI.ModalDialog.showModalDialog(options);
}     
</ script>

In the body
< a href="#" onclick="OpenDialog();">Open Dialog


PS: Use to avoid the execute script load errors. SP.SOD.execute("sp.ui.dialog.js", "SP.UI.ModalDialog.showModalDialog", e);

Dialog Option
title: "Dialog Title" --> to set title for pop up window
allowMaximize: dialogAllowMaximize, -----> To allow maximize
showClose: dialogShowClose, ------> Show close button options



Advance Options: Modal Dialog Options Call backs


To handle the Ok or Cancel from Modal Dialog window, you can use the scripts as follows

Option 1: To refresh on any action of modal box  use below in option dialogReturnValueCallback:RefreshOnDialogClose
 Example:

< script type="text/javascript">
function OpenDialog(){        
var options = {            
url:'http://pageurlcomeshere',            
width: 500,            
height: 300,
dialogReturnValueCallback: RefreshOnDialogClose
};          
SP.UI.ModalDialog.showModalDialog(options);
}      
</ script>

Option 2:  To refresh on Ok but not close/cancel events
dialogReturnValueCallback: CheckOnDialogClose  //( below is the method)

OR

dialogReturnValueCallback: function(dialogResult) { if (dialogResult != SP.UI.DialogResult.cancel){SP.UI.ModalDialog.RefreshPage(dialogResult)}}


 Examples:
 function OpenDialog()
{
var e = {
            title: "Dialog Title",
            url: "http://Server/Pages/message.aspx",
            width: 500,
            height: 250,
           dialogReturnValueCallback: function(dialogResult)
        {
            if (dialogResult != SP.UI.DialogResult.cancel)
            {
                SP.UI.ModalDialog.RefreshPage(dialogResult)
            }
     }
            //dialogReturnValueCallback: CheckOnDialogClose
        };
        SP.SOD.execute("sp.ui.dialog.js", "SP.UI.ModalDialog.showModalDialog", e);

}


/* Separate function to handle popup return back calls*/

function CheckOnDialogClose(result, target) {

     if(result==SP.UI.DialogResult.OK) {
        SP.UI.ModalDialog.RefreshPage(dialogResult)
       }
        if(result==SP.UI.DialogResult.cancel){ 
/*
          SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel,'Cancel Clicked');
           alert("Canceled Clicked"); //No refresh
*/
          }    

 }


Article Source: http://msdn.microsoft.com/en-us/library/office/ff410058%28v=office.14%29.aspx

Happy Browsing!
Relax..