mbischof/yii2-datatables

Yii2 扩展,用于 DataTables jQuery 插件

1.0.1 2018-03-04 17:45 UTC

This package is not auto-updated.

Last update: 2024-09-24 17:17:19 UTC


README

Yii2 小部件,用于 DataTables jQuery 插件

安装

安装此扩展的首选方式是通过 composer。

运行以下命令之一:

composer require mbischof/yii2-datatables

或者

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

将以下内容添加到您的 composer.json 文件的 require 部分:

基本用法

<?= \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(); ?>