formating/stylising getAsHtml output

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

formating/stylising getAsHtml output

Postby Neale » Thu Nov 18, 2004 8:46 am

Hi,

I have an SQL report (nasty example of "cross-tab") which functions OK but the output from getAsHtml() is somewhat lacking - mostly with the numbers (integers) being suffixed with ".0" and left-justified.

I can deal with the ".0" suffix (simple string.replace()) but the left justification (which should be right justification for columns of numbers) has me stumped.

Does Servoy provide any way to influence the formatting in getAsHtml?

Thanks,
Neale.
Neale
 
Posts: 230
Joined: Thu May 15, 2003 6:29 am
Location: Australia

Postby Jan Blok » Thu Nov 18, 2004 11:19 am

No it does not provide any formatting, we might add this in the future, but the code for creating a html table is very simple:
Code: Select all
var out = '';
var numberOfColumns = set.getColumnCount();
out += '<TABLE BORDER=1 CELLPADDING=1 CELLSPACING=0>'
out += '<TR>'
for(var x = 1; x <= numberOfColumns ; x++)
{
   out += '<TD><B>'+getColumnName(x)+'</B></TD>'
}
out += '</TR>'
for(var j = 1 ; j <= set.getRowCount() ; j++)
{
   out += '<TR>'
   for(int x = 1; x <= numberOfColumns ; x++)
   {
      out += '<TD>'+set.getValue(j,x)+'</TD>'
   }
   out += '</TR>'
}
out += '</TABLE>'
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Postby Neale » Fri Nov 19, 2004 5:39 am

Thanks for the tip. For the record, here's the version I'm using:

Code: Select all
var out = '';
var numberOfColumns = dataset1.getMaxColumnIndex();
out += '<TABLE BORDER=1 CELLPADDING=1 CELLSPACING=0>'
out += '<TR ALIGN=CENTER>'
for(var x = 1; x <= numberOfColumns ; x++)
{
   out += '<TH><B>'+dataset1.getColumnName(x)+'</B></TH>'
}
out += '</TR>'
for(var j = 1 ; j <= dataset1.getMaxRowIndex() ; j++)
{
   out += '<TR ALIGN=RIGHT>'
   // Handle first column (row labels) specially...
   out += '<TD ALIGN=LEFT>'+dataset1.getValue(j,1)+'</TD>'
   for(var x = 2; x <= numberOfColumns ; x++)
   {
      out += '<TD>'+dataset1.getValue(j,x)+'</TD>'
   }
   out += '</TR>'
}
out += '</TABLE>'


The <TH> tag somehow coerces the table headings to lower-case, but apart from that it's fine (doesn't even confuse the issue with ".0" suffixes on integers).

Thanks,
Neale.
Neale
 
Posts: 230
Joined: Thu May 15, 2003 6:29 am
Location: Australia


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 39 guests

cron