我的索引页面上没有显示我的分页。
有人可以告诉我如何为我的索引页面创建限制为15的分页吗?
public function actionIndex()
{
$searchModel = new EmployeeSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$pagination = new Pagination([
'defaultPageSize' => 5,
'totalCount' =>$this->count(),
]);
$employee = $query->orderBy('name')
->offset($pagination->offset)
->limit($pagination->limit)
->all();
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'Employee-create' => $employee,
'pagination' => $pagination,
]);
}
答案 0 :(得分:0)
您可以通过这种方式为数据提供者设置pageSize
$searchModel = new EmployeeSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$dataProvider->pagination->pageSize=15;
答案 1 :(得分:0)
在您的文件中,EmployeeSearch.php包含参数分页
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => 15,
],
]);