View
Код: Выделить всё
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;
/* @var $this yii\web\View */
/* @var $searchModel common\models\CatalogCounterpartiesSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Контрагенты';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="catalog-counterparties-index">
<?php
Pjax::begin([
'id' => 'catalog-counterparties-index',
'timeout' => 10000,
'enablePushState' => false,
]);
?>
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a('Добавить Контрагента', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?=
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'options' => ['data-pjax' => false],
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'name',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{select} {create-copy}',
'buttons' => [
'create-copy' => function ($url) {
return Html::a(Html::tag('span', '', ['class' => "glyphicon glyphicon-copy"]), $url, ['class' => 'btn btn-success btn-xs', 'title' => 'Добавить копированием']);
},
'select' => function ($url) {
return Html::a(Html::tag('span', '', ['class' => "glyphicon glyphicon-ok"]), $url, ['class' => 'btn btn-success btn-xs', 'title' => 'Выбрать']);
},
]
],
],
]);
?>
<?php Pjax::end(); ?>
</div>
Код: Выделить всё
public function actionIndex() {
$searchModel = new CatalogCounterpartiesSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
if (Yii::$app->request->isAjax) {
return $this->renderAjax('_pjax-index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
} else {
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
}