Thursday, May 29, 2014

SharePoint 2010/2013 - Notifications options



SharePoint provide OTB model dialog which can be used from client side to show a message or loading splash which you load a application page on your model dialog. Below are the options that can be used in a content editor or JavaScript file on your SharePoint page.
Add this tag to avoid null ref error ( like 'SP.UI.Notify' is null or not an object or 
Message: 'SP.UI.ModalDialog' is null or not an object).
 < script src="/_layouts/SP.UI.Dialog.js" type="text/javascript" >
or
Try adding this in code after option declaration while calling popup.
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);

To give a Loading Notification for a model dialog. 
Start of displaying the notification
var waitDialog = SP.UI.ModalDialog.showWaitScreenWithNoClose('Working on it', 'Please wait while we load your screen...', 70, 340);
To Stop the loading Screen
waitDialog.close();
If you want to display notification in the top right corner then use this.
To Start notification
var notification;
ExecuteOrDelayUntilScriptLoaded(function () 
notification = SP.UI.Notify.addNotification("BI Charts are getting loaded!", true);
});
 // ExecuteOrDelayUntilScriptLoaded this function prevent the null ref error and it wait till the SP.UI.Dialog.js loads.
To Stop notification
SP.UI.Notify.removeNotification(notification);
---------Example-----------------------

< script type="text/ecmascript" language="ecmascript" >

var statusId = '';
var notifyId = '';

function AddNotification() {
    notifyId = SP.UI.Notify.addNotification("Hello World!", true);
}

function RemoveNotification() {
    SP.UI.Notify.removeNotification(notifyId);
    notifyId  = '';
}

function AddStatus() {
    statusId = SP.UI.Status.addStatus("Status good!");
    SP.UI.Status.setStatusPriColor(statusId, 'red');
}

function RemoveLastStatus() {
    SP.UI.Status.removeStatus(statusId);
    statusId = '';
}

function RemoveAllStatus() {
    SP.UI.Status.removeAllStatus(true);
}

< /script >
 
PS: Please correct the tags spacing and add js file ref.

Source: https://msdn.microsoft.com/en-us/library/office/ee658473%28v=office.14%29.aspx

Happy Browsing!
Relax..

Saturday, May 10, 2014

SharePoint 2010 - Remove Chart Webpart  Default Options Display



To hide the legends and Other information ( Data options) from the Chart Webpart, Set ShowToolbar="False" from the SharePoint Designer in XSLT mode.



Happy Browsing!
Relax..

Friday, April 18, 2014

SharePoint 2013/2010 - Remove Columns Name from Group View

 To remove the column name from group view and retaining the collapse and expand option,copy and paste the below javascript in the page using content editor or script editor.

JavaScript (SharePoint 2013/SharePoint 2010):
<script type="text/javascript" language="javascript">
        _spBodyOnLoadFunctionNames.push("HideHeaders");
        function HideHeaders() {
            var elements = getElementsByClassName(document, "td", "ms-gb");
            var elem;
            for (var i = 0; i < elements.length; i++) {
                elem = elements[i];
                elem.childNodes[0].childNodes[1].nodeValue = "";
                elem.childNodes[1].nodeValue = elem.childNodes[1].nodeValue.replace(':', '');
            }
            elements = getElementsByClassName(document, "td", "ms-gb2");
            for (var i = 0; i < elements.length; i++) {
                elem = elements[i];
                elem.childNodes[1].childNodes[1].nodeValue = "";                elem.childNodes[2].nodeValue = elem.childNodes[2].nodeValue.replace(':', '');
            }
        }
        function getElementsByClassName(oElm, strTagName, strClassName) {
            var arrElements = (strTagName == "*" && oElm.all) ? oElm.all : oElm.getElementsByTagName(strTagName);
            var arrReturnElements = new Array();
            strClassName = strClassName.replace(/\-/g, "\\-");
            var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
            var oElement;
            for (var i = 0; i < arrElements.length; i++) {
                oElement = arrElements[i];
                if (oRegExp.test(oElement.className)) {
                    arrReturnElements.push(oElement);
                }
            }
            return (arrReturnElements)
        }
    </script>

Thanks to Source Article: http://amitphule.blogspot.com/2011/10/hiding-group-headers-from-sharepoint.html  

Happy Browsing!
Relax..