PHP code example of kak / grid
1. Go to this page and download the library: Download kak/grid library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kak / grid example snippets
use kak\widgets\grid\GridView;
use yii\helpers\Html;
echo GridView::widget([
'showFooter' => true,
'dataProvider' => $provider,
'columns' => [
'user' => [
'header' => 'user',
'format' => 'html',
'value' => function($data){
return '[' . $data->stream_id . '] '
. Html::a($data->user->name,['user/update', 'id' => $data->user->id ]);
}
],
'date_key',
'os',
'browser',
'operator_id' => [
'header' => 'Operator',
'value' => 'operator.name'
],
'country_id' => [
'header' => 'Country',
'format' => 'html',
'value' => function($data){
return Html::img($data->country->flag_url,['title' => $data->country->name_ru]);
},
'footer' => '<b>Total redirect</b>',
],
'view_count' => [
'attribute' => 'view_count',
'summary' => 'sum'
],
'redirect_count' => [
'attribute' => 'redirect_count',
'summary' => 'sum'
],
'ratio (redirect/view)' => [
'header' => 'Ratio',
'value' => function($data){
return round( (int)$data->redirect_count/(int)$data->view_count ,2);
}
],
'actions' => [
'class' => \yii\grid\ActionColumn::className(),
'template' => '{view}',
],
]
])