PHP code example of amenophis1er / yii2-datatables
1. Go to this page and download the library: Download amenophis1er/yii2-datatables library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
amenophis1er / yii2-datatables example snippets
use yii\web\Controller;
use amenophis1er\yii2datatables\DataTablesComponent;
use app\models\User;
class SiteController extends Controller
{
public function actionDemo()
{
$query = User::find()
->select(['id', 'username', 'email', 'status', 'created_at', 'updated_at'])
->where(['like', 'username', 'a%', false]);
$datatables = \Yii::$app->datatables->register($query, function ($row) {
// Optionally modify each row data here
$row['action'] = "<a href='#'>Update</a>";
unset($row['password_hash']);
return $row;
});
return $this->render('demo', ['datatables' => $datatables]);
}
}