Answer the question
In order to leave comments, you need to log in
How to replace GridView with DynaGrid?
Good afternoon. Of course, I can google. But there is little information about DynaGrid on the Internet and basically everything is in English. I translated and looked, but I really didn’t understand anything how to replace GridView with DynaGrid in my Index.php.
I have already uploaded the kartik and the DynaGrid itself through the composer. Tried several options and failed.
Here is my original GridView code:
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'name',
['attribute'=>'description',
'label'=>'Описание', ],
[
'attribute'=>'id_avtor1',
'label'=>'Автор',
'format'=>'text',
'content'=>function($data){
return $data->getAvtor1Name();
},
'filter' => [ '1' => 'Джоан Роулинг', '2' => 'Стивен Кинг', '3' => 'Джон Рональд Руэл Толкин'],
],
['attribute' =>
'creation_date',
'value'=>'creation_date',
'content'=>function($data){
return Yii::$app->formatter->asDatetime($data->creation_date);
},
'format'=>'raw',
'filter'=>DatePicker::widget([
'model'=>$searchModel,
'attribute'=>'creation_date',
'clientOptions'=>[
'autoclose'=>true,
'format'=>'yyyy-mm-dd',
]
]
)
],
['attribute' => 'date_of_change',
'value'=>'date_of_change',
'content'=>function($data){
return Yii::$app->formatter->asDatetime($data->date_of_change);
},
'format'=>'raw',
'filter'=>DatePicker::widget([
'model'=>$searchModel,
'attribute'=>'date_of_change',
'clientOptions'=>[
'autoclose'=>true,
'format'=>'yyyy-mm-dd',
]
]
)
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
Answer the question
In order to leave comments, you need to log in
1. Add DynaGrid to your configuration as a module
'modules'=>[
'dynagrid'=> [
'class'=>'\kartik\dynagrid\Module',
// other module settings
],
'gridview'=> [
'class'=>'\kartik\grid\Module',
// other module settings
],
];
<?= \kartik\dynagrid\DynaGrid::widget([
'columns' => $columns,
'theme'=>'panel-warning',
'gridOptions'=>[
'dataProvider'=>$dataProvider,
'filterModel'=>$searchModel,
'showPageSummary'=>true,
'panel'=>[
'heading'=>'<h3 class="panel-title"><i class="glyphicon glyphicon-book"> Library',
'before'=>'{dynagrid}' . Html::a('Custom Button', '#', ['class'=>'btn btn-secondary'])
],
]
]); ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question