<?= GridView::widget([
'filterUrl' => Url::toRoute('index'),
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'tableOptions' => ['id' => 'navigation', 'class' => 'table table-striped table-bordered'],
'rowOptions' => function ($model, $key, $index){
$children_count = $model->level;
$a = array();
array_push($a,$model->level);
if($model->level == 1){
$class = "tn-container expanded";
}elseif($children_count > 1){
$class = 'tn-container collapsed';
}else{
$class = 'tn-container';
}
return [
'class' => $class,
'level' => $model->level,
'parent' => $model->level-1,
'children_count' => $model->children_count,
'node' => $model->level+1,
];
},
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
[
'attribute'=>'navigations_types__alias',
'label'=> $Package->t('', 'Тип ссылки'),
'format'=>'text',
'content'=>function($data){
if ($data->object != null)
return $data->object->title;
},
'filter' => NavigationsObjects::getList()
],
[
'attribute'=>'navigations_targets__alias',
'label'=> $Package->t('', 'Цель ссылки'),
'format'=>'text',
'content'=>function($data){
if ($data->target != null)
return $data->target->title;
},
'filter' => NavigationsTargets::getList()
],
'alias',
'navigation_label',
'icon',
'pretty_url',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} '
],
],
]); ?>