PHP完全自学手册(珍藏版) 中文pdf扫描版下载
yii2.0 利用Activedataprovider分页
use yii\data\ActiveDataProvider; 这是必须的步骤,因为我们要使用 ActiveDataProvider 类
use common\models\User;
public function actionList()
{
$model = new User();
$dataProvider = new ActiveDataProvider([
'query' => $model->find();
'pagination => [
'pagesize' => '10',
]
]);
return $this->render('list', ['model' => $model, 'dataProvider' => $dataProvider]);
}
use yii\grid\GridView; 这是必须的;
GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'attribute',(attribute为字段的名称,开发时候根据自己的需要进行修改)
[
'attribute' => 'create_time',
'format' => ['data', 'Y-m-d H:i:s'],
'options' => ['width' => '200']
]],
['class' => 'yii\grid\ActionColumn', 'header' => '操作', 'headerOptions' => ['width' => '80']],
]);
use yii\data\ActiveDataProvider; 这是必须的步骤,因为我们要使用 ActiveDataProvider 类
use common\models\User;
public function actionList()
{
$model = new User();
$dataProvider = new ActiveDataProvider([
'query' => $model->find();
'pagination => [
'pagesize' => '10',
]
]);
return $this->render('list', ['model' => $model, 'dataProvider' => $dataProvider]);
}
use yii\grid\GridView; 这是必须的;
GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'attribute',(attribute为字段的名称,开发时候根据自己的需要进行修改)
[
'attribute' => 'create_time',
'format' => ['data', 'Y-m-d H:i:s'],
'options' => ['width' => '200']
]],
['class' => 'yii\grid\ActionColumn', 'header' => '操作', 'headerOptions' => ['width' => '80']],
]);
转载请注明:谷谷点程序 » yii2.0 利用Activedataprovider分页