2017 © Pedro Peláez
 

yii2-extension yii2-widget-datatables

DataTables widget for Yii2

image

dbfernandes/yii2-widget-datatables

DataTables widget for Yii2

  • Wednesday, September 6, 2017
  • by dbfernandes
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 17 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

DataTables widget for Yii2

This extension provides the DataTables integration for the Yii2 framework. It was originally proposed by fedemotta., (*1)

Installation

The preferred way to install this extension is through composer., (*2)

With Composer installed, you can then install the extension using the following commands:, (*3)

composer global require "fxp/composer-asset-plugin:~1.0.0"
composer require --prefer-dist dbfernandes/yii2-widget-datatables "*"

The first command installs the composer asset plugin which allows managing bower and npm package dependencies through Composer. You only need to run this command once for all. The second command installs the datatables widget., (*4)

You can also add (instead of the second command):, (*5)

"dbfernandes/yii2-widget-datatables": "*"

to the require section of your composer.json file., (*6)

Usage

Use DataTables as any other other Yii2 widget., (*7)

use dbfernandes\datatables\DataTables;
search(Yii::$app->request->queryParams);
?>
= DataTables::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],

        //columns

        ['class' => 'yii\grid\ActionColumn'],
    ],
]);?>

This extension uses the Bootstrap integration plugin to provide a Yii2 style by default., (*8)

The TableTools plugin is also available. Specify the DOM and the tableTools settings in the clientOptions array as the following example., (*9)

...
'clientOptions' => [
    "lengthMenu"=> [[20,-1], [20,Yii::t('app',"All")]],
    "info"=>false,
    "responsive"=>true,
    "dom"=> 'lfTrtip',
    "tableTools"=>[
        "aButtons"=> [  
            [
            "sExtends"=> "copy",
            "sButtonText"=> Yii::t('app',"Copy to clipboard")
            ],[
            "sExtends"=> "csv",
            "sButtonText"=> Yii::t('app',"Save to CSV")
            ],[
            "sExtends"=> "xls",
            "oSelectorOpts"=> ["page"=> 'current']
            ],[
            "sExtends"=> "pdf",
            "sButtonText"=> Yii::t('app',"Save to PDF")
            ],[
            "sExtends"=> "print",
            "sButtonText"=> Yii::t('app',"Print")
            ],
        ]
    ]
],
...

You can also use DataTables in the JavaScript layer of your application. To achieve this, you need to include DataTables as a dependency of your Asset file. In this case, you could use yii\grid\GridView or using the datatables options retrieve => true to avoid errors. In both case all options must be in the Javascript object., (*10)

public $depends = [
...
'dbfernandes\datatables\DataTablesAsset',
...
];

The Versions

06/09 2017

dev-master

9999999-dev

DataTables widget for Yii2

  Sources   Download

MIT

The Requires

  • yiisoft/yii2 *
  • bower-asset/jquery >= 1.7.0
  • bower-asset/datatables >= 1.9.4
  • bower-asset/datatables-bootstrap3 *
  • bower-asset/datatables-tabletools *

 

by David Fernandes de Oliveira

extension library yii2 jquery javascript table datatables

08/06 2015

v1.3

1.3.0.0

DataTables widget for Yii2

  Sources   Download

MIT

The Requires

  • yiisoft/yii2 *
  • bower-asset/jquery >= 1.7.0
  • bower-asset/datatables >= 1.9.4
  • bower-asset/datatables-bootstrap3 *
  • bower-asset/datatables-tabletools *

 

by Federico Nicolás Motta

extension library yii2 jquery javascript table datatables

03/06 2015

v1.2

1.2.0.0

DataTables widget for Yii2

  Sources   Download

MIT

The Requires

  • yiisoft/yii2 *
  • bower-asset/jquery >= 1.7.0
  • bower-asset/datatables >= 1.9.4
  • bower-asset/datatables-bootstrap3 *
  • bower-asset/datatables-tabletools *

 

by Federico Nicolás Motta

extension library yii2 jquery javascript table datatables

27/05 2015

v1.1

1.1.0.0

DataTables widget for Yii2

  Sources   Download

MIT

The Requires

  • yiisoft/yii2 *
  • bower-asset/jquery >= 1.7.0
  • bower-asset/datatables *
  • bower-asset/datatables-bootstrap3 *

 

by Federico Nicolás Motta

extension library yii2 jquery javascript table datatables

26/05 2015

v1.0

1.0.0.0

DataTables widget for Yii2

  Sources   Download

MIT

The Requires

 

by Federico Nicolás Motta

extension library yii2 jquery javascript table datatables