1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: execut |
5
|
|
|
* Date: 11/15/17 |
6
|
|
|
* Time: 12:14 PM |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace execut\actions\widgets; |
10
|
|
|
|
11
|
|
|
use execut\yii\jui\WidgetTrait; |
12
|
|
|
use kartik\export\ExportMenu; |
13
|
|
|
use yii\helpers\ArrayHelper; |
14
|
|
|
use yii\helpers\Html; |
15
|
|
|
use \kartik\dynagrid\DynaGrid as KartikDynaGrid; |
16
|
|
|
|
17
|
|
|
class DynaGrid extends KartikDynaGrid |
18
|
|
|
{ |
19
|
|
|
use WidgetTrait; |
20
|
|
|
public $dataProvider = null; |
21
|
|
|
public $storage = KartikDynaGrid::TYPE_DB; |
22
|
|
|
public $filter = null; |
23
|
|
|
|
24
|
|
|
public function init() |
25
|
|
|
{ |
26
|
|
|
$columns = $this->filter->getGridColumns(); |
27
|
|
|
$fullExportMenu = ExportMenu::widget([ |
28
|
|
|
'dataProvider' => $this->dataProvider, |
29
|
|
|
'columns' => $columns, |
30
|
|
|
'target' => ExportMenu::TARGET_BLANK, |
31
|
|
|
'batchSize' => 1000, |
32
|
|
|
'fontAwesome' => true, |
33
|
|
|
'asDropdown' => false, |
34
|
|
|
'dropdownOptions' => [ |
35
|
|
|
'label' => '<i class="glyphicon glyphicon-export"></i> Full' |
36
|
|
|
], |
37
|
|
|
]); |
38
|
|
|
|
39
|
|
|
$this->columns = $columns; |
40
|
|
|
|
41
|
|
|
$this->gridOptions = ArrayHelper::merge([ |
42
|
|
|
'class' => GridView::class, |
43
|
|
|
'responsive' => false, |
44
|
|
|
'responsiveWrap' => false, |
45
|
|
|
'rowOptions' => function ($row) { |
46
|
|
|
if (method_exists($row, 'getRowOptions')) { |
47
|
|
|
return $row->getRowOptions(); |
48
|
|
|
} |
49
|
|
|
}, |
50
|
|
|
'panel' => false, |
51
|
|
|
'export' => [ |
52
|
|
|
'fontAwesome' => true, |
53
|
|
|
'itemsAfter'=> [ |
54
|
|
|
'<li role="presentation" class="divider"></li>', |
55
|
|
|
'<li class="dropdown-header">Export All Data</li>', |
56
|
|
|
$fullExportMenu |
57
|
|
|
] |
58
|
|
|
], |
59
|
|
|
'toggleDataOptions' => [ |
60
|
|
|
'maxCount' => 100000, |
61
|
|
|
], |
62
|
|
|
'filterModel' => $this->filter, |
63
|
|
|
// 'toolbar' => $this->getToolbarConfig(), |
|
|
|
|
64
|
|
|
'dataProvider' => $this->dataProvider, |
65
|
|
|
], $this->gridOptions); |
66
|
|
|
|
67
|
|
|
parent::init(); // TODO: Change the autogenerated stub |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getGridId() { |
71
|
|
|
return $this->id . '-grid'; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @inheritdoc |
76
|
|
|
*/ |
77
|
|
|
public function run() |
78
|
|
|
{ |
79
|
|
|
$this->gridOptions['options']['id'] = $this->id; |
80
|
|
|
|
81
|
|
|
Html::addCssClass($this->options, $this->getDefaultCssClass()); |
82
|
|
|
$this->_registerBundle(); |
83
|
|
|
|
84
|
|
|
echo Html::tag('div', GridView::widget($this->gridOptions), $this->options); |
85
|
|
|
} |
86
|
|
|
} |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.