Yii2 Widget for DataTables plug-in for jQuery
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.
<?= \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(); ?>