PHP Classes

File: docs/column/template.md

Recommend this page to a friend!
  Classes of Matous Nemec   PHP Data Grid View   docs/column/template.md   Download  
File: docs/column/template.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: PHP Data Grid View
Display data in an editable grid on a Web page
Author: By
Last change:
Date: 3 years ago
Size: 3,073 bytes
 

Contents

Class file image Download

Implements

Methods for ^Mesour\DataGrid\Column\Template^

| Method | Default | Possible values | Returns | Required | Description | |--------------------|:-------:|------------------------|-----------------------------------|----------|------------------------------------------------| | setTempDirectory | 0 | int $decimals | ^Mesour\DataGrid\Column\Template^ | yes | Path to writable temp dir | | setTemplateFile | . | string $decimalPoint | ^Mesour\DataGrid\Column\Template^ | yes | Path to template file | | setBlock | none | string $unit | ^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=[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
$source->setPrimaryKey('user_id');

$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();