ok look a bit deeper into the concatting of strings.
what you should do is not use + but call concat..
That will speedup the current setup…
But i also optimized the code beneath the concat method so that in the next RC release it will be even much faster..
var maxReturnedRows = arguments[0]
var query = arguments[1]
var headerBgColor = '#cccccc'
var rowBgcolorLight = '#faf9f9'
var rowBgcolorDark = '#edeaea'
var dataset = databaseManager.getDataSetByQuery(currentcontroller.getServerName(), query, null, maxReturnedRows);
var HTML = '<html>'.concat(
'<HEAD>',
'<style type="text/css">',
' .header{',
' font-family: Verdana, Verdana, Arial, Helvetica, sans-serif;',
' font-size: 9px;',
' background-color: #999999;',
' border: 12px solid #000000;',
' color: #ffffff; text-decoration: none;}',
' .body{',
' font-family: Verdana, Verdana, Arial, Helvetica, sans-serif;',
' font-size: 9px;',
' color: #000000; text-decoration: none;}',
' </style>',
'</HEAD>',
'<TABLE border=1 class="body">');
//create headers
HTML = HTML.concat('<TR class="header" >');
for(var i=1 ; i <= dataset.getMaxColumnIndex() ; i++)
{
HTML = HTML.concat('<TD border=0>', dataset.getColumnName(i) , '</TD>');
}
HTML = HTML.concat('</TR>');
//create rows and columns
for( var i = 1 ; i <= dataset.getMaxRowIndex() ; i++ )
{
dataset.rowIndex = i;
//set rowBgColor
if(i%2==0)
{
HTML = HTML.concat('<TR bgcolor=',rowBgcolorLight,'>');
}
else
{
HTML = HTML.concat('<TR bgcolor=',rowBgcolorDark,'>');
}
for(var j=1 ; j <= dataset.getMaxColumnIndex() ; j++)
{
HTML = HTML.concat('<TD border=0>',dataset[j],'</TD>');
}
HTML = HTML.concat('</TR>');
}
HTML = HTML.concat('</TABLE>');
return HTML;
It will still slow down a bit when it gets larger and larger. But by far not that exponential.
Notice the , instead of the + !!