Skip to content

Suggestion to add an optional no results found row when rendering as HTML.  #98

@aNorthernSoul

Description

@aNorthernSoul

It would be nice to have an option to have the renderRowHtml output a row with a configurable message if no results were found. For example, in the renderRowHtml function, you could simply do something like:

`
private function renderRowHtml()
{
$data = $this->getTable()->getData();
$headers = $this->getTable()->getHeaders();
$render = '';

    if ( !sizeof($data) ) {
        return sprintf('<tr %s><td colspan="%s">%s</td></tr>', $this->getAttributes(), sizeof($this->getTable()->getHeaders()), 'There is no data to display.');
    }
    
    foreach ($data as $rowData) {
        $this->setActualRow($rowData);
        $rowRender = '';

        foreach ($headers as $name => $options) {
            $rowRender .= $this->getTable()->getHeader($name)->getCell()->render('html');
        }

        foreach ($this->decorators as $decorator) {
            $decorator->render('');
        }

        $render .= sprintf('<tr %s>%s</tr>', $this->getAttributes(), $rowRender);
        $this->clearVar();
    }
    return $render;

}
`

Ideally the message could be set in the table class extending AbstractTable so that it could be unique to each table but even the above would be handy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions