Pjax::begin([‘id‘=>‘datalist‘]); echo GridView::widget([ ‘dataProvider‘ => $dataProvider, ‘columns‘ => [ [‘class‘ => yii\grid\CheckboxColumn::className()], ‘id‘, [ ‘header‘ => ‘姓名‘, ‘label‘ => ‘姓名‘, ‘attribute‘ => ‘name‘ ], [ ‘header‘ => ‘职位‘, ‘label‘ => ‘职位‘, ‘attribute‘ => ‘position‘ ], [ ‘header‘ => ‘手机‘, ‘label‘ => ‘手机‘, ‘attribute‘ => ‘mobile‘ ], [ ‘header‘ => ‘状态‘, ‘label‘ => ‘状态‘, ‘attribute‘ => ‘status‘, ‘value‘ => function($data) { return app\models\intro_user::getStatus()[$data->status]; } ], [ ‘header‘ => ‘操作‘, ‘class‘ => ‘yii\grid\ActionColumn‘, ], ], ‘layout‘ => "{items}\n{summary}\n<div style=\"text-align:center;\">{pager}</div>", ‘summary‘ => false, //‘summaryOptions‘=>[‘class‘ => ‘summary‘], ]); Pjax::end();
其他的一些链接需要使用pjax时这么用(不能使用js的跳转,支持a标签,和form):
<?php $this->beginBlock(‘pagejs‘); ?> $(function () { /*search start*/ $(‘.usico-search‘).on(‘click‘, function () { var name = $.trim($(‘.search‘).val()); if (name) { //window.location.href = ‘<?= Url::to([‘/oamanager‘]) ?>?name=‘ + name; } else { $(‘.search‘).focus(); return false; } }); /*search end*/ jQuery(document).pjax("button a[link-pjax]", "#datalist", {"push":true,"replace":false,"timeout":1000,"scrollTo":false}); jQuery(document).on(‘submit‘, "form[data-pjax]", function (event) {jQuery.pjax.submit(event, ‘#datalist‘, {"push":true,"replace":false,"timeout":1000,"scrollTo":false});}); }); <?php $this->endBlock(); ?> <?php $this->registerJs($this->blocks[‘pagejs‘], \yii\web\View::POS_END); //将编写的js代码注册到页面底部 ?>
时间: 2024-11-02 03:52:47