The extension provides different columns for yii\grid\GridView
widget. You can see it on this page.
There is a GridView
demo below.
ID | Name + slug | Price | Old Price | Price | Is Active | Quantity | Reserved |
---|---|---|---|---|---|---|---|
21 | Product #21product-21 | 1.88 ↓ -95% | 100 | ||||
22 | Product #22product-22 | 10345345 ↓ -99% | 100 | ||||
23 | Product #23product-23 | 52000345345 ↑ 362389% | 100 | ||||
24 | Product #24product-24 | 30345345 ↑ 0% | 100 | ||||
25 | Product #25product-25 | 11111111111345 ↓ -96% | 100 | ||||
26 | Product #26product-26 | 155345 ↑ 2806% | 100 | ||||
27 | Product #27product-27 | 1231345 ↑ 9874% | 100 | ||||
28 | Product #28product-28 | 1230345 ↑ 5170% | 100 | ||||
29 | Product #29product-29 | 8034345 ↑ 85874% | 100 | ||||
30 | Product #30product-30 | 22222 ↓ -96% | 100 |
The column allows to show a current value and difference between it and last value.
Parameters
attribute
string the attribute name associated with this columntemplate
string|callable the string output template or the render callabledifference
string|callable the difference attribute name or the calculation callabledifferenceInPercents
bool whether to show difference in percentsyii\grid\DataColumn
Example
[ 'class' =>\yiister\grid\widgets\DifferenceColumn::className(), 'attribute' => 'price', 'difference' => function ($model, $column) { return $model->price - $model->old_price; }, 'differenceInPercents' => true, 'template' => '{value} <sup class="label label-info">{difference}%</sup>', ],
The column allows to update value via ajax.
Parameters
attribute
string the attribute name associated with this columnupdateAction
array|string the update action route. See ColumnUpdateActionsize
string the input sizeyii\grid\DataColumn
Example
[ 'class' => \yiister\grid\widgets\InputColumn::className(), 'attribute' => 'price', 'updateAction' => '/projects/column-update', ],
The column allows to show some fields in one column by template.
Parameters
attribute
string the attribute name associated with this columnattributes
string[] the secondary attribute names arraytemplate
string|callable the string output template or the render callableyii\grid\DataColumn
Example
[ 'class' => \yiister\grid\widgets\MultifieldColumn::className(), 'attribute' => 'name', 'label' => 'Name + slug', 'attributes' => ['slug'], 'template' => '{name}<br /><small><code>{slug}</code></small>', ],
The column allows to show a progressbar for associated attribute value.
Parameters
attribute
string the attribute name associated with this columnpercent
bool whether to show a percents instead of an attribute valueminValue
int the minimum attribute valuemaxValue
int the maximum attribute valueshowText
bool whether to show the textsize
string the progress bar sizeprogressBarClass
string|callback the progress bar classisStriped
bool whether to stripe the progress barisAnimated
bool whether to animate the progress baryii\grid\DataColumn
Example
[ 'class' => \yiister\grid\widgets\ProgressColumn::className(), 'attribute' => 'reserved', 'size' => \yiister\grid\widgets\ProgressColumn::SIZE_LARGE, 'isStriped' => true, 'progressBarClass' => function ($model, $column) { return $model->{$column->attribute} > 15 ? \yiister\grid\widgets\ProgressColumn::STYLE_SUCCESS : \yiister\grid\widgets\ProgressColumn::STYLE_WARNING; }, ],
The column allows to show toggle buttons with ability to change value via ajax request.
Parameters
attribute
string the attribute name associated with this columnbuttons
array of values to rendering[ 'value_one' => 'The first label', 'value_two' => 'The second label', ]
updateAction
array|string the update action route. See ColumnUpdateActionyii\grid\DataColumn
Example
[ 'class' => \yiister\grid\widgets\ToggleColumn::className(), 'attribute' => 'is_active', 'updateAction' => '/projects/column-update', ],
The action for column updating. It is used in ajax requests of some columns.
Parameters
allowedAttributes
array of allowed classes with attributes in the next format
[ 'app\models\Page' => ['is_active'], 'app\models\OrderStatus' => ['is_system', 'is_active', 'sort_order'], ]
Example
public function actions() { return [ 'column-update' => [ 'class' => ColumnUpdateAction::className(), 'allowedAttributes' => [ 'app\models\DemoProduct' => ['price', 'old_price', 'is_active'], ], ], ]; }