# yii2-datatables **Repository Path**: tiglog/yii2-datatables ## Basic Information - **Project Name**: yii2-datatables - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-10-01 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README yii2 datatables ================ ## install ```sh composer require tiglog\yii2-datatables bower install --save datatables datatables-plugins ``` ## usage ```php // controller use app\models\Post; use app\models\datatable\FooDt; class FooController extends Controller { public function actions() { return [ 'bar' => [ 'class' => 'tiglog\datatables\DataAction', 'dt' => new FooDt(Post::find()), ], ]; } public function actionIndex() { $dt = new FooDt(Post::find()); return $this->render('index', [ 'dt' => $dt, ]); } } // model class FooDt extends \tiglog\datatables\BaseDt { public function columns() { return [ ['attribute' => 'id', 'searchable' => true], ['attribute' => 'name', 'type' => 'string'], 'summary', ['label' => 'foo', 'value' => 'bar'], ['label' => 'hello', 'value' => function ($model, $column) { return 'world'; }], ['attribute' => 'created_at', 'format' => ['date', 'php:Y-m-d H:i']], ]; } } // view echo \tiglog\datatables\DataTable::widget([ 'columns' => $dt->getColumns(), // 'data' => $dt->getData(), 'clientOptions' => [ 'serverSide' =>true, 'ajax' => '/foo/bar', ], ]); ```