コード例 #1
0
 /**
  * Renders data grid body.
  * @return string
  */
 public function renderBody()
 {
     $container = $this->getWrapper('datagrid container');
     // headers
     $header = Html::el($container->getName() == 'table' ? 'thead' : NULL);
     $header->add($this->generateHeaderRow());
     if ($this->dataGrid->hasFilters()) {
         $header->add($this->generateFilterRow());
     }
     // footer
     $footer = Html::el($container->getName() == 'table' ? 'tfoot' : NULL);
     $footer->add($this->generateFooterRow());
     // body
     $body = Html::el($container->getName() == 'table' ? 'tbody' : NULL);
     $iterator = new SmartCachingIterator($this->dataGrid->getRows());
     foreach ($iterator as $data) {
         $row = $this->generateContentRow($data);
         $row->addClass($iterator->isEven() ? $this->getValue('row.content .even') : NULL);
         $body->add($row);
     }
     if ($container->getName() == 'table') {
         $container->add($header);
         $container->add($footer);
         $container->add($body);
     } else {
         $container->add($header);
         $container->add($body);
         $container->add($footer);
     }
     return $container->render(0);
 }
コード例 #2
0
ファイル: DataGridRenderer.php プロジェクト: jurasm2/datagrid
 /**
  * Renders data grid body.
  * @return string
  */
 public function renderBody()
 {
     $table = $this->getWrapper('datagrid container');
     // headers
     $table->add($this->generateHeaderRow());
     // filters
     if ($this->dataGrid->hasFilters()) {
         $table->add($this->generateFilterRow());
     }
     // rows
     $iterator = new \Nette\SmartCachingIterator($this->dataGrid->getRows());
     foreach ($iterator as $data) {
         $row = $this->generateContentRow($data);
         $row->class[] = $iterator->isEven() ? $this->getValue('row.content .even') : '';
         $table->add($row);
     }
     // footer
     $table->add($this->generateFooterRow());
     return $table->render(0);
 }