123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- use \app\models\base\Comments;
- use yii\helpers\Html;
- use yii\helpers\Url;
- use yii\grid\ActionColumn;
- use yii\grid\GridView;
- /** @var yii\web\View $this */
- /** @var yii\data\ActiveDataProvider $dataProvider */
- $this->title = 'Список комментариев';
- $this->params['breadcrumbs'][] = $this->title;
- ?>
- <div class="comments-index">
- <?php \yii\widgets\Pjax::begin([
- 'timeout'=>5000,
- 'enablePushState'=>false
- ])?>
- <?
- // $dataProvider->setSort([
- // 'attributes' => [
- // 'created_at'
- // ]
- // ]);
- /*
- $dataProvider->sort = ['attributes' => [
- 'created_at' =>
- [
- 'asc' => ['created_at' => SORT_ASC],
- 'desc' => ['created_at' => SORT_DESC],
- 'default' => SORT_DESC
- ],
- ]];*/
- ?>
- <?= GridView::widget([
- 'dataProvider' => $dataProvider,
- 'filterModel' => $searchModel,
- 'layout' => "{errors}\n{summary}\n{pager}\n{items}\n{pager}",
- 'tableOptions' => ['id'=>'utab', 'class' => 'table table-striped table-bordered table-min'],
- 'filterPosition' =>'header',
- 'pager' => [
- 'prevPageCssClass' => 'page-item',
- 'firstPageLabel' => 'Начало',
- 'lastPageLabel' => 'Конец',
- 'linkOptions' => [ 'class'=>'page-link'],
- 'pageCssClass' => 'page-item',
- 'disabledListItemSubTagOptions' => ['tag' => 'a', 'class' => 'page-link'],
- ],
- 'columns' => [
- 'created_at',
- ['label'=>"Новость","format"=>"raw","value"=>fn($model)=>isset( $model->post->title )?Html::a($model->post->title,$model->post->getUrl(),["target"=>"_blank"]):''],
- 'message:ntext',
- 'fakename',
- 'ip_address',
- //['label'=>"user_agent","format"=>"raw","value"=>fn($model)=>isset( $model->user_agent )?$model->user_agent:''],
- 'user_agent',
- [
- 'class' => ActionColumn::className(),
- 'template' => '{view}',
- 'urlCreator' => function ($action, Comments $model, $key, $index, $column) {
- return Url::toRoute([$action, 'id' => $model->id]);
- },
- 'header'=>"Действия",
- 'buttonOptions' => ['class' => 'btn btn-default btn-sm'],
- 'contentOptions'=>['style'=>'min-width: 40px;'],
- 'options' =>
- [
- 'class' => 'nowrap',
- ],
- ],
- ],
- ]); ?>
- <?php \yii\widgets\Pjax::end()?>
- </div>
- <script>
- $('#utab').DataTable({
- paging: false,
- columnDefs: [
- {
- orderable: false,
- targets: 1
- },
- {
- orderable: false,
- targets: 2
- },
- {
- orderable: false,
- targets: 6
- },
- {
- orderable: false,
- targets: 6
- },
- {
- orderable: false,
- targets: 6
- },
- {
- orderable: false,
- targets: 6
- },
- ],
- "responsive": true, "lengthChange": false, "autoWidth": false,
- // order: [[1, 'desc']]
- });
- $('.dataTables_length').addClass('bs-select');
- </script>
- <style>
- .table-min td{ max-width:450px; width: auto;}
- </style>
|