mbischof/yii2-datatables

Yii2 Extension for DataTables jQuery plug-in

1.0.1 2018-03-04 17:45 UTC

This package is not auto-updated.

Last update: 2024-04-23 15:31:39 UTC


README

Yii2 Widget for DataTables plug-in for jQuery

Installation

The preferred way to install this extension is through composer.

Either run

composer require mbischof/yii2-datatables

or add

"mbischof/yii2-datatables": "~1.0"

to the require section of your composer.json file.

Basic Usage

<?= \mbi\datatables\BootstrapDatatableWidget::begin([
    'tableOptions' => [
        'class' => 'table table-striped table-bordered',
        'width' => '100%',
        'cellspacing' => 0
    ]
]) ?>

    <thead>
        <tr>
            <th>Id</th>
            <th>Firstname</th>
            <th>Lastname</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
    <?php foreach ($persons as $person): ?>
        <tr>
            <td style="text-align: center"><?= $person->id; ?></td>
            <td><?= $person->firstname; ?></td>
            <td><?= $person->lastname; ?></td>
            <td style="text-align: center"><?= Html::a(FA::icon('trash'), ['person/delete', 'id' => $person->id], ['data-method' => 'post']); ?></td>
        </tr>
    <?php endforeach; ?>
    </tbody>

<?= \mbi\datatables\BootstrapDatatableWidget::end(); ?>