有两个例子:刷新时间和数据显示排序
1、刷新时间
(1)控制器中的方法:Time
public function actionTime() { return $this->render(‘time‘,[‘time‘=>date("h:i:s")]); }
(2)视图中的显示:Time.php
<?php use yii\widgets\Pjax; use yii\helpers\Html; ?> <? Pjax::begin()?> <?=Html::a(‘time‘,[‘hello/time‘],[‘class‘=>‘btn btn-lg btn-primary‘])?> <h3>Current Time:<?=$time?></h3> <? Pjax::end()?>
(2)数据显示的排序:
只需要在GridView显示的地方加上Pjax即可:
<?Pjax::begin();?> <?echo GridView::widget([ ‘dataProvider‘ => $dataProvider, ‘filterModel‘ => $searchModel, ‘columns‘ => [ [‘class‘ => ‘yii\grid\CheckboxColumn‘], ‘id‘, ‘name‘, ‘password‘, [‘class‘ => ‘yii\grid\ActionColumn‘, ], ], ]); ?> <?Pjax::end();?>
时间: 2024-12-29 04:37:03