Agile Tortoise
Greg Pierce’s blog
« Servoy newsletter Flotsam or jetsam? »
Servoy: simple HTML progress bar
I have several places in Servoy solutions where it's nice to display a simple progress bar to the user. This is for workflows, where the user needs a visual for how far along they are on the task/job/etc. -- not for actual progress on executing code.
I wrote a simple global method you can call from a dataprovider calculation to get back an HTML table that mimics a progress bar. So, if I've got a field (or calculation) on a table "progress_percent", that returns the percent complete on a item, I can also create a method that calls this global, passing in the percent field as an argument, returning a nice little visual of the progress -- like this,

And here's the code:
-
var progress = arguments[0];
-
if ( progress == null )
-
return null;
-
-
var html = "<html><head>";
-
-
html += "<style>";
-
html += "td{font: 8pt Arial;}\n";
-
html += "td.green{background-color:#AAFFAA;}\n";
-
html += "td.red{background-color:#FFAAD4;}\n";
-
html += "</style>";
-
-
html += "</head><body>";
-
html += "<table width='100%' cellspacing='1' cellpadding='0' border='0'>";
-
html += "<tr>";
-
-
for( var ix = 0; ix <100; ix=ix+10 )
-
{
-
if( ix <progress )
-
html += "<td class='green' nowrap='nowrap'> </td>";
-
else
-
html += "<td class='red' nowrap='nowrap'> </td>";
-
}
-
-
html += "</tr>";
-
html += "</table>";
-
html += "</body></html>";
-
return html;
January 9th, 2008 at 3:15 am
Great Tip…