SharePoint 2010 Cookbook: Working with the Status Bar in SharePoint 2010

Among the useful new features in SharePoint 2010 are the enhancements available with the addition of the Status Bar, helping to provide a more productive experience for users. This seemingly small feature can be used in extremely creative and interesting ways to enhance your own custom SharePoint applications. In this post, we will take a look a how to work with messages on the Status Bar in SharePoint 2010.

Challenge:

How do I show, modify, and remove a message on the Status Bar in SharePoint 2010?

Solution:

What is the Status Bar Message?

The Status Bar is extensible through both client- or server-side code, and is used to display a persistent message to users. The Status Bar message is rendered in HTML, so it can be styled and may contain links and images. In addition, the bar can have four different preset colors, in accordance with the importance of the message.

 

Working with the SharePoint 2010 Status Bar is very easy. Its functionality is exposed through the SP.UI.Status namespace (defined in the 14TEMPLATELAYOUTSSP.js file) in the SharePoint 2010 JavaScript API.

How to use the Status Bar

In order to display a message in the SharePoint 2010 Status Bar, you use the SP.UI.Status.addStatus function. This function takes three parameters: the title of the status, the status message itself, and a Boolean value which determines whether the status message should be displayed at first or not.  For example:

var statusBarId = SP.UI.Status.addStatus('My Status:', ‘Do You Bamboo?’, true);

Results in the following Status Bar message:

The addStatus function returns the ID of the status message, which can be used to modify the message, change its color, etc.

About Priority

Status Bar messages are meant to provide feedback to users. To support this, SharePoint allows you to set four visual priorities for the message using different colored feedback. From the most to the least important, the available colors are: red, yellow, green, and blue.

You can set the priority of a status message using the SP.UI.Status.setStatusPriColor function. This function takes two parameters: the ID of the status message and the color that you want to set:

SP.UI.Status.setStatusPriColor = function(statusBarId, color) { 
 
}

For example:

SP.UI.Status.setStatusPriColor(statusBarId, 'red');

Results in changing the color of the status message to red:

 

Update Status Message

Status messages should be displayed only when necessary and meaningful. As soon as the status of the application changes, you should modify the status message or hide it.

To modify the value of a status message, you use the SP.UI.Status.updateStatus function. It takes two parameters: the ID of the message and the new message:

SP.UI.Status.updateStatus = function(statusBarId, newMessage) {
}

Remove Status Message

Whenever the status of the application changes and the message that has been displayed doesn’t apply anymore, you can hide the message using the SP.UI.Status.removeStatus function. The only parameter that it takes is the ID of the status message to be hidden:

SP.UI.Status.removeStatus = function(statusBarId){
}

 

Notes:

 

See Also:


SharePoint Online

The cloud parts are functional components that extend your SharePoint Online environment in Microsoft 365.

Supports Classic and Modern sites for SharePoint Online/Microsoft 365

SharePoint

Top SharePoint Online Products

Experience greater power and savings by bundling our SharePoint apps and cloud parts.


Calendar Plus


Chart Plus


Knowledge Base


Project Management Central


Simple List Search

 

On-Premises Only

These web parts extend SharePoint beyond its out-of-the-box capabilities by tailoring it to your requirements with Bamboo Solution’s growing portfolio of SharePoint Web Parts.

SharePoint 2013, 2016, 2019 – Classic Pages Only

SharePoint

Top On-Premises Only Products

Experience greater power and savings by bundling our SharePoint apps and web parts.


Calendar Plus


Data Viewer


Password Change


Password Expiration


Password Reset

 

Our team of Microsoft 365 experts help you get the most out of your Microsoft technology, we have the best Microsoft 365 talent to streamline your organization.

Streamline Your Department

We Have What You Need

Bamboo Solutions

Tools


Resources


Bamboo Installer