TBaseDataList is the base class for data listing controls, including
{@link TDataList} and {@link TDataGrid}.
The key field in the data source is specified by {@link setKeyField KeyField},
while {@link getKeyValues KeyValues} stores the key values of each record in
a data listing control. You may use the list item index to obtain the corresponding
database key value.
TBaseDataList also implements a few properties used for presentation based
on tabular layout. The {@link setCaption Caption}, whose alignment is
specified via {@link setCaptionAlign CaptionAlign}, is rendered as the table caption.
The table cellpadding and cellspacing are specified by
{@link setCellPadding CellPadding} and {@link setCellSpacing CellSpacing}
properties, respectively. The {@link setGridLines GridLines} specifies how
the table should display its borders, and the horizontal alignment of the table
content can be specified via {@link setHorizontalAlign HorizontalAlign}.
/** * Renders the openning tag for the datagrid control which will render table caption if present. * @param THtmlWriter the writer used for the rendering purpose */ public function renderBeginTag($writer) { parent::renderBeginTag($writer); if (($caption = $this->getCaption()) !== '') { if (($align = $this->getCaptionAlign()) !== TTableCaptionAlign::NotSet) { $writer->addAttribute('align', strtolower($align)); } $writer->renderBeginTag('caption'); $writer->write($caption); $writer->renderEndTag(); } }
/** * Renders the data list control. * This method overrides the parent implementation. * @param THtmlWriter writer for rendering purpose. */ public function render($writer) { if ($this->getHasControls()) { if ($this->getItemCount() > 0) { $this->applyItemStyles(); $repeatInfo = $this->getRepeatInfo(); $repeatInfo->renderRepeater($writer, $this); } else { if ($this->_emptyTemplate !== null || $this->getEmptyRenderer() !== '') { parent::render($writer); } } } }