Announcement

Collapse
No announcement yet.

Transformer to convert aggregate SQL results to an HTML TAble

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transformer to convert aggregate SQL results to an HTML TAble

    This was derived from and inspired by the aggregate SQL to CSV converter by TonyG at http://www.mirthcorp.com/community/f...17&postcount=8

    Posting this to give back a little.

    Code:
    //derived from Agermano aggregate to CSV converter from http://www.mirthcorp.com/community/forums/showpost.php?p=264817&postcount=8
    //Tony Germano is a genius and a very generous person
    msg.setName('table'); 
    [email protected] = '1px solid black;';
    
    //get the name of each element and add it as a header row
    var headerRow = new XML('<tr/>');
    for each (var element in msg.result[0].children()){
    	if (element != null){
    		var name = element.name();
    		var headerColumn = new XML('<th>' + name + '</th>');
    		headerRow.appendChild(headerColumn);
    	}
    }
    msg.prependChild(headerRow);
    
    //convert the children to tr's and their children to td's
    for each (var result in msg.result){
    	for each (var element in result.children()){
    		element.setName('td');
    	}
    	
    	result.setName('tr');
    }
    Last edited by jbartels; 02-15-2019, 11:16 AM. Reason: fix url
    Jon Bartels

    Zen is hiring!!!!
    http://consultzen.com/careers/
    Talented healthcare IT professionals wanted. Engineers to sales to management.
    Good benefits, great working environment, genuinely interesting work.
Working...
X