2017 © Pedro PelĂĄez
 

yii2-extension yii2-datatables

A Yii2 extension to provide the framework with the JQuery DataTables plugin

image

jlorente/yii2-datatables

A Yii2 extension to provide the framework with the JQuery DataTables plugin

  • Thursday, June 21, 2018
  • by jlorente
  • Repository
  • 1 Watchers
  • 0 Stars
  • 34 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 1 Versions
  • 21 % Grown

The README.md

DataTables widget for Yii2

The extension is inspired by the yii2-widget-datatables by fedemotta., (*1)

This extension provides the DataTables integration for the Yii2 framework., (*2)

Latest Stable Version Total Downloads Latest Unstable Version License, (*3)

Installation

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

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

$ php composer.phar require jlorente/yii2-datatables "*"

or add, (*6)

...
    "require": {
        // ... other configurations ...
        "jlorente/yii2-datatables": "*"
    }

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

Usage

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

use jlorente\datatables\grid\DataTables;
$searchModel = new ModelSearch();
$dataProvider = $searchModel->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., (*9)

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

DataTables::widget([
    //Other configurations
    '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., (*11)

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

The Versions

21/06 2018

dev-master

9999999-dev

A Yii2 extension to provide the framework with the JQuery DataTables plugin

  Sources   Download

MIT

The Requires

  • bower-asset/datatables >= 1.9.4
  • bower-asset/datatables-bootstrap3 *
  • bower-asset/datatables-tabletools *

 

by Federico NicolĂĄs Motta
by Jose Lorente Martin

extension library yii2 jquery javascript table datatables