Template column

Implements

Methods for Mesour\DataGrid\Column\Template

Method Default Possible values Returns Required Description
setTempDirectory none int $tempDirectory Mesour\DataGrid\Column\Template yes Path to writable temp dir
setTemplateFile none string $templateFile Mesour\DataGrid\Column\Template yes Path to template file
setBlock none string $block Mesour\DataGrid\Column\Template no Specify block in your template
setCallback none callable $callback Mesour\DataGrid\Column\Template no Can add variables to template in this callback

Callback parameters for method setCallback

Parameter Type Description
$column Mesour\DataGrid\Column\Template Template column instance
$rowData Mesour\Sources\ArrayHash / Entity / ActiveRow Data for current row
$templateFile Mesour\DataGrid\TemplateFile Template file instance

Events

Info See onRenderon events page

Usage

$mesourApp = //instance Mesour\Components\Application\IApplication
$source = //some <a href="http://components.mesour.com/version3/component/sources/" target="_blank">data source</a> or two-dimensional array

$grid = new Mesour\UI\DataGrid('numberDataGrid', $mesourApp);

$grid->setSource($source);

//! here add column template
$grid->addTemplate('name', 'Name')
    ->setTempDirectory( __DIR__ . '/../../../temp/cache')
    ->setTemplateFile(__DIR__ . '/../templates/test.latte')
    ->setBlock('test2')
    ->setCallback(function (\Mesour\DataGrid\Column\Template $column, $data, \Mesour\DataGrid\TemplateFile $templateFile) {
        $templateFile->name = $data['name'];
    });

$grid->addText('surname', 'Surname');

$grid->addText('email', 'E-mail');

$grid->render();

Demo


NameSurnameE-mail
test2 JohnDoejohn.doe@test.xx
test2 PeterLarsonpeter.larson@test.xx
test2 ClaudeGravesclaude.graves@test.xx
test2 StuartNormanstuart.norman@test.xx
test2 KathyArnoldkathy.arnold@test.xx
test2 JanWilsonjan.wilson@test.xx
test2 AlbertaEricksonalberta.erickson@test.xx
test2 AdaWellsada.wells@test.xx
test2 EthelFigueroaethel.figueroa@test.xx
test2 IanGoodwinian.goodwin@test.xx
test2 FrancisHayesfrancis.hayes@test.xx
test2 ErmaBurnserma.burns@test.xx
test2 KristinaJenkinskristina.jenkins@test.xx
test2 VirgilHuntvirgil.hunt@test.xx
test2 MaxMartinmax.martin@test.xx
test2 MelodyManningmelody.manning@test.xx
test2 CatherineToddcatherine.todd@test.xx
test2 DouglasStanleydouglas.stanley@test.xx
test2 PattiDiazpatti.diaz@test.xx
test2 JohnPettersonjohn.petterson@test.xx