« Home | Backup, Restore & Publish Dynamics CRM Customizati... » | 'The application is already precompiled' error » | Server Explorer Gone Invisible? » | Month Name from Month Number » | Implemeting SSL in IIS 7.0 » | Maintain Scroll Position on PostBack in ASP.NET » | Offline Mode of your WebSite » | Handy Extension Methods for ASP.NET MVC's UrlHelper » | Credit Card Expiration Date DropDownList Sample Code » | Visual Studio Automatically Changing the IDs in So... »

Progress Bar in Dynamics CRM 4.0

To create a progress bar in Dynamics CRM 4.0 like the one below





You need the following


2.step.gif  
 

3.statusbar.gif - You can get this from the /_imgs/ folder in CRM

For step.gif, right click the .gif file and save it on your system.

crmprogressbar.js

function crmProgressBar(id) {
this.bar = $("#" + id);

this.bar.css({
'height': '23px',
'width': '357px',
'background': 'transparent url(img/statusbar.gif) no-repeat'
});

this.bar.find("div").css({
'height': '19px',
'width': '1px',
'background': 'transparent url(img/step.gif) repeat-x',
'position': 'relative',
'top': '2px',
'left': '3px'
});

this.step = function(percentage) {
var width = parseInt((percentage / 100) * 351);
if (width > 351) { width = 351; }

this.bar.find("div").css({ 'width': width + 'px' });
}
}

To implement follow the steps below.

1.Create a new html file
2.Create a new javascript file and copy the above code into it
3.Include a reference to the jQuery javascript library
4.Include a reference to the javascript in your html file
5.Add a "div" tag to the html file and give it an "id"
6.Add another "div" tag inside the "div" you created in step 4. and put a blank space
7.To initialize the progress bar; create a new variable to hold the progress bar, then create a new instance of the progress bar by specifying the "id" of the div you created in step 4.
eg: var progressBar1 = new crmProgressBar("id-of-div");
8.To step/increment the progress bar use the step() instance method
eg: progressBar1.step(10); // will increment to 10%;



<div id="p1">
<div>
 </div>
</div>

<script type="text/javascript">
var i = 5;
var cpb = null;

$(document).ready(function() {
cpb = new crmProgressBar("p1");
increment();
});

function increment() {
if (i <= 100) {
i += 5;
cpb.step(i);
setTimeout(increment, 1000);
}
}

</script>


Happy Coding..

You can find gperera's entry on Blog

Labels: , , , , ,

Post a Comment