-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2015 Yiister | ||
* @license https://github.com/yiister/yii2-gentelella/blob/master/LICENSE | ||
* @link http://gentelella.yiister.ru | ||
*/ | ||
namespace yiister\gentelella\widgets\grid; | ||
|
||
use yii\helpers\Html; | ||
|
||
class DataColumn extends \yii\grid\DataColumn | ||
{ | ||
public function renderHeaderCell() | ||
{ | ||
$provider = $this->grid->dataProvider; | ||
if ($this->attribute !== null && $this->enableSorting && | ||
($sort = $provider->getSort()) !== false && $sort->hasAttribute($this->attribute)) { | ||
if (($direction = $sort->getAttributeOrder($this->attribute)) !== null) { | ||
Html::addCssClass($this->headerOptions, 'sorting_' . ($direction === SORT_DESC ? 'desc' : 'asc')); | ||
} else { | ||
Html::addCssClass($this->headerOptions, 'sorting'); | ||
} | ||
} | ||
return Html::tag('th', $this->renderHeaderCellContent(), $this->headerOptions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2015 Yiister | ||
* @license https://github.com/yiister/yii2-gentelella/blob/master/LICENSE | ||
* @link http://gentelella.yiister.ru | ||
*/ | ||
|
||
namespace yiister\gentelella\widgets\grid; | ||
|
||
use yii\helpers\Html; | ||
|
||
class GridView extends \yii\grid\GridView | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public $dataColumnClass = 'yiister\gentelella\widgets\grid\DataColumn'; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public $tableOptions = ['class' => 'table dataTable']; | ||
|
||
/** | ||
* @var bool whether to border grid cells | ||
*/ | ||
public $bordered = true; | ||
|
||
/** | ||
* @var bool whether to condense the grid | ||
*/ | ||
public $condensed = false; | ||
|
||
/** | ||
* @var bool whether to stripe the grid | ||
*/ | ||
public $striped = true; | ||
|
||
/** | ||
* @var bool whether to add a hover for grid rows | ||
*/ | ||
public $hover = false; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function init() | ||
{ | ||
if ($this->bordered) { | ||
Html::addCssClass($this->tableOptions, 'table-bordered'); | ||
} | ||
if ($this->condensed) { | ||
Html::addCssClass($this->tableOptions, 'table-condensed'); | ||
} | ||
if ($this->striped) { | ||
Html::addCssClass($this->tableOptions, 'table-striped'); | ||
} | ||
if ($this->hover) { | ||
Html::addCssClass($this->tableOptions, 'table-hover'); | ||
} | ||
parent::init(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function run() | ||
{ | ||
GridViewAsset::register($this->view); | ||
parent::run(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function renderPager() | ||
{ | ||
return Html::tag('div', parent::renderPager(), ['class' => 'dataTables_paginate paging_simple_numbers']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2015 Yiister | ||
* @license https://github.com/yiister/yii2-gentelella/blob/master/LICENSE | ||
* @link http://gentelella.yiister.ru | ||
*/ | ||
|
||
namespace yiister\gentelella\widgets\grid; | ||
|
||
class GridViewAsset extends \yii\web\AssetBundle | ||
{ | ||
public $sourcePath = '@vendor/bower/gentelella/vendors/datatables.net-bs/css'; | ||
public $css = [ | ||
'dataTables.bootstrap.min.css', | ||
]; | ||
public $js = []; | ||
public $depends = [ | ||
'yiister\gentelella\assets\Asset', | ||
]; | ||
} |