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 |
---|---|---|---|---|---|---|---|
1 | Product #1product-1 | 66 ↑ 230% | 100 | ||||
2 | Product #2product-2 | 5000 ↑ 1006% | 100 | ||||
3 | Product #3product-3 | 1234 ↑ 1286% | 100 | ||||
4 | Product #4product-4 | 2000 ↑ 5782% | 100 | ||||
5 | Product #5product-5 | 5891 ↑ 0% | 100 | ||||
6 | Product #6product-6 | 444321 ↓ -26% | 100 | ||||
7 | Product #7product-7 | 80 ↓ -99% | 100 | ||||
8 | Product #8product-8 | 6789 ↑ 675% | 100 | ||||
9 | Product #9product-9 | 6 ↓ -93% | 100 | ||||
10 | Product #10product-10 | 451456 ↓ -99% | 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'], ], ], ]; }