/** * Wraps the content cell in a <td> element * * @param TableHeaderCellModel $tableHeader * @param TableRowModel $tableRow * @param string $tdClass * @return string */ public static function printCustomTableCell(TableHeaderCellModel $tableHeader, TableRowModel $tableRow, $tdClass = "kolom") { $tdClass = empty($tableHeader->getHtmlClass()) ? $tdClass : $tableHeader->getHtmlClass(); $string = "<td class=\"%1\$s\">" . $tableHeader->getHtmlContent() . "</td>"; return sprintf($string, $tdClass . ' ' . $tableHeader->getSafeName(), $tableRow->getCellValue('id')); }
/** * Parses result rows (as an associative array) into the model instance by creating * TableRowModels containing TableCellModels. These models will contain the name and value * at minimum, but might contain more properties like "visible", "safeName" or their dataTypes * * @see TableRowModel * @see TableModel::tableRows * @param array $rowData containing TableRowModel objects * @throws \Exception */ public function addRows(array $rowData) { if (empty($this->tableHeaders)) { throw new \Exception("Please provide the table model with table header information first"); } foreach ($rowData as $row) { $tableRow = new TableRowModel(); $tableRow->setCells($this->parseCells($row)); $this->tableRows[] = $tableRow; } }
/** * Wrapper foreach row in the table * * @param TableRowModel $tableRow * @return string */ protected function printTableContentRow(TableRowModel $tableRow) { $html = ''; /** @var TableHeaderCellModel $tableHeader */ foreach ($this->displayedHeaders as $tableHeader) { $cell = $tableRow->getCell($tableHeader->getSafeName()); if (!$cell) { $cell = null; } $html .= $this->printTableContentCell($cell); } if (in_array('simpleSearch', $this->displaySettings)) { /** @var TableFilterModel $filter */ foreach ($this->additionalFilters as $filter) { $html .= $this->printTableContentCell($filter->getInstance()->getFilterCellValue($tableRow)); } } if (in_array('actionRoutes', $this->displaySettings)) { $links = $this->tableModel->getOptionRoutes(); $html .= '<td class="kolom rowOptions"><span class="pull-right iconenNaarLinks">'; foreach ($links as $action => $url) { $html .= $this->getActionLink($action, $url, $tableRow->getCellValue('id')); } $html .= '</span></td>'; } return $html; }