Status column

Documentation

Methods

Method Default Possible values Returns Required
setId none String (column name) $this Yes
setHeader none String $this Yes
setOrdering TRUE TRUE or FALSE $this No
addButton none none Instance of Components\StatusButton. No
setAttributes none array of attributes $this No
setAttribute none $key, $value, $append = FALSE $this No

Events

Event Description
onRender Fired before cell is rendered

Initializing

use Mesour\DataGrid\NetteDbDataSource,
    Mesour\DataGrid\Grid,
    Mesour\DataGrid\Components\Link;

protected function createComponentStatusDataGrid($name) {
    $source = new NetteDbDataSource($this->demo_model->getUserSelection());

    $table_id = 'user_id';

    $grid = new Grid($this, $name);

    $grid->setPrimaryKey($table_id);

    $grid->setDataSource($source);

    $status_column = $grid->addStatus('action', 'S');

    $status_column->addButton()
        ->setStatus('0')// show if status == 0
        ->setType('btn-danger')
        ->setClassName('ajax')
        ->setIcon('glyphicon-ban-circle')
        ->setTitle('Set as active (unactive)')
        ->setAttribute('href', new Link('changeStatusUser!', array(
            'id' => '{' . $table_id . '}',
            'status' => 1
        )));

    $status_column->addButton()
        ->setStatus('1')// show if status == 1
        ->setType('btn-success')
        ->setClassName('ajax')
        ->setIcon('glyphicon-ok-circle')
        ->setTitle('Set as unactive (active)')
        ->setAttribute('href', new Link('changeStatusUser!', array(
            'id' => '{' . $table_id . '}',
            'status' => 0
        )));

    $grid->addText('name', 'Name');

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

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

    return $grid;
}

Demo

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