A small piece of code to use SharePoint 2010 Status Bar from a SharePoint 2010 list (“Alerts”):
Example Bar:
The script:
<script type=”text/javascript” src=”jquery-1.6.1.min.js”></script>
<script type=”text/javascript”>
ExecuteOrDelayUntilScriptLoaded(statusinit,
“sp.js”);
function statusinit() {
var statusId = ”;
var notifyId = ”;
function AddStatus(title, bericht, kleur)
{
statusId =
SP.UI.Status.addStatus(title, bericht, true);
SP.UI.Status.setStatusPriColor(statusId,
kleur);
}
$(document).ready(function() {
var soapEnv =
“<soapenv:Envelope
xmlns:soapenv=’http://schemas.xmlsoap.org/soap/envelope/’> \
<soapenv:Body> \
<GetListItems xmlns=’http://schemas.microsoft.com/sharepoint/soap/’> \
<listName>Alerts</listName> \
<viewFields> \
<ViewFields> \
<FieldRef Name=’Title’ /> \
<FieldRef Name=’Bericht’ /> \
<FieldRef Name=’Kleur’ /> \
</ViewFields> \
</viewFields> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>”;
$.ajax({
url: “http://<yourportal>/_vti_bin/lists.asmx”,
type: “POST”,
dataType: “xml”,
data: soapEnv,
complete:
processResult,
contentType: “text/xml; charset=\”utf-8\”"
});
});
function processResult(xData, status) {
$(xData.responseXML).find(“[nodeName='z:row']“).each(function() {
AddStatus($(this).attr(‘ows_Title’)+”:”, $(this).attr(‘ows_Bericht’), $(this).attr(‘ows_Kleur’));
});
}
}
</script>
How to use?
Create a Custom List with the the following columns:
Make them required.
For Kleur (Color) you can choose the following colors: blue, green, yellow and
red.
The Title will be displayed Bold.
Example:
The Status Bar will be displayed on the page like:
Multiple status Bars:
If you don’t want to put this code in a Page Layout or Master page, use a Content Editor Web Part on the page.
Have fun!