Text column

Implements

Methods for Mesour\DataGrid\Column\Text

Method Default Possible values Returns Required Description
setCallback none callable $callback Mesour\DataGrid\Column\Text no If you use callback, column shows output of this callback

Callback parameters for method setCallback

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

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 some text columns
$grid->addText('surname', 'Name with surname')
    ->setCallback(function (Mesour\DataGrid\Column\Text $column, $rowData) {
        return $rowData['name'] . ' ' . $rowData['surname'];
    });

$grid->addText('email', 'E-mail')
    ->setCallback(function (Mesour\DataGrid\Column\Text $column, $rowData) {
        return Mesour\Components\Utils\Html::el('a', [
            'href' => 'mailto:' . $rowData['email']
        ])->add($rowData['email']);
    });

$grid->render();

Demo


Name with surnameE-mail
John Doejohn.doe@test.xx
Peter Larsonpeter.larson@test.xx
Claude Gravesclaude.graves@test.xx
Stuart Normanstuart.norman@test.xx
Kathy Arnoldkathy.arnold@test.xx
Jan Wilsonjan.wilson@test.xx
Alberta Ericksonalberta.erickson@test.xx
Ada Wellsada.wells@test.xx
Ethel Figueroaethel.figueroa@test.xx
Ian Goodwinian.goodwin@test.xx
Francis Hayesfrancis.hayes@test.xx
Erma Burnserma.burns@test.xx
Kristina Jenkinskristina.jenkins@test.xx
Virgil Huntvirgil.hunt@test.xx
Max Martinmax.martin@test.xx
Melody Manningmelody.manning@test.xx
Catherine Toddcatherine.todd@test.xx
Douglas Stanleydouglas.stanley@test.xx
Patti Diazpatti.diaz@test.xx
John Pettersonjohn.petterson@test.xx