Global.helma.Html.table (headers, data, param)
render a complete x/html table

  • Parameter Array:
    an array containing table headers
  • Parameter Array:
    a 2 dimensional array containing the table data
  • Parameter Object:
    the table's, its rows' and cells' attributes
Sourcecode in /home/hannes/helma/modules/helma/Html.js:
506:   this.table = function(headers, data, param) {
507:           if (!param) {
508:               res.write("[Html.table: insufficient arguments]");
509:               return;
510:           }
511:           var attr = Object.clone(param);
512:           if (!attr.trHead) attr.trHead = attr.tr;
513:           if (!attr.trEven) attr.trEven = attr.tr;
514:           if (!attr.trOdd)  attr.trOdd = attr.tr;
515:          if (!attr.tdEven) attr.tdEven = attr.td;
516:          if (!attr.tdOdd)  attr.tdOdd = attr.td;
517:          if (!attr.thEven) attr.thEven = attr.th;
518:          if (!attr.thOdd)  attr.thOdd = attr.th;
519:          self.openTag("table", attr.table);
520:          if (headers) {
521:              self.openTag("tr", attr.trHead);
522:              for (var i in headers) {
523:                  var evenOdd = i % 2 == 0 ? "Even" : "Odd";
524:                  self.openTag("th", attr["th"+evenOdd]);
525:                  res.write(headers[i]);
526:                  self.closeTag("th");
527:              }
528:              self.closeTag("tr");
529:          }
530:          for (var i in data) {
531:              var evenOdd = i % 2 == 0 ? "Even" : "Odd";
532:              self.openTag("tr", attr["tr"+evenOdd]);
533:              for (var j in data[i]) {
534:                  var evenOddCell = j % 2 == 0 ? "Even" : "Odd";
535:                  self.openTag("td", attr["td"+evenOddCell]);
536:                  res.write(data[i][j]);
537:                  self.closeTag("td");
538:              }
539:              self.closeTag("tr");
540:          }
541:          self.closeTag("table");
542:      }