Render events

Event onRender on Mesour\DataGrid\Column\IColumn

FIRED before column is rendered. For all rows.
Info Can use for all columns
$grid->addText('name', 'Name')
    ->onRender[] = function(Mesour\DataGrid\Column\Text $column, $rowData, $data) {
        if($rowData['amount'] > 1500) {
            $column->setAttribute('class', 'color-green');
        } else {
            $column->setAttribute('class', 'color-red');
        }
    };
Argument Type Description
$column Mesour\DataGrid\Column\IColumn Current column instance
$rowData Mesour\Sources\ArrayHash / Entity / ActiveRow Data for current row
$data Mesour\Sources\ArrayHash / ArrayAccess / array Data as array

Events on Mesour\UI\DataGrid

Event onRender

FIRED if rendering started
$grid->onRender[] = function (Mesour\UI\DataGrid $grid, $rawData, $data) {
    // do some SQL for save sort
};
Argument Type Description
$grid Mesour\UI\DataGrid Current grid instance
$rowData Mesour\Sources\ArrayHash / Entity / ActiveRow Data for current row
$data Mesour\Sources\ArrayHash / ArrayAccess / array Data as array

Event onRenderColumnHeader

FIRED before create header cell. For all columns
$grid->onRenderColumnHeader[] = function (Mesour\DataGrid\Column\IColumn $column, $index, $columnCount) {
    // do something
};
Argument Type Description
$column Mesour\DataGrid\Column\IColumn Column instance
$index int Column index
$columnCount int Total column count

Event onRenderHeader

FIRED after create header
$grid->onRenderHeader[] = function (Mesour\Table\Render\Header $header, $rowData, $data) {
    // do something
};
Argument Type Description
$header Mesour\Table\Render\Header Header renderer instance
$rowData Mesour\Sources\ArrayHash / Entity / ActiveRow Data for current row
$data Mesour\Sources\ArrayHash / ArrayAccess / array Data as array

Event onRenderRow

FIRED after create row
$grid->onRenderRow[] = function (Mesour\Table\Render\Row $row, $rowData, $data) {
    // do something
};
Argument Type Description
$row Mesour\Table\Render\Row Row renderer instance
$rowData Mesour\Sources\ArrayHash / Entity / ActiveRow Data for current row
$data Mesour\Sources\ArrayHash / ArrayAccess / array Data as array

Event onAfterRenderRow

FIRED after attach row to Mesour\Table\Render\Body
$grid->onAfterRenderRow[] = function (Mesour\Table\Render\Body $body, $index, $rowData, $data) {
    // do something
};
Argument Type Description
$body Mesour\Table\Render\Body Body renderer instance
$index int Index in data from fetchAll()
$rowData Mesour\Sources\ArrayHash / Entity / ActiveRow Data for current row
$data Mesour\Sources\ArrayHash / ArrayAccess / array Data as array

Event onRenderBody

FIRED if body is created
$grid->onRenderBody[] = function (Mesour\Table\Render\Body $body, $rawData, $data) {
    // do some SQL for save sort
};
Argument Type Description
$body Mesour\Table\Render\Body Body renderer instance
$rowData Mesour\Sources\ArrayHash / Entity / ActiveRow Data for current row
$data Mesour\Sources\ArrayHash / ArrayAccess / array Data as array