本文整理汇总了PHP中yii\data\ActiveDataProvider::setPagination方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveDataProvider::setPagination方法的具体用法?PHP ActiveDataProvider::setPagination怎么用?PHP ActiveDataProvider::setPagination使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\data\ActiveDataProvider
的用法示例。
在下文中一共展示了ActiveDataProvider::setPagination方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setPagination
/**
* Sets the pagination for this data provider.
* @param array|Pagination|boolean $value the pagination to be used by this data provider.
* This can be one of the following:
*
* - a configuration array for creating the pagination object. The "class" element defaults
* to 'yii\data\Pagination'
* - an instance of [[Pagination]] or its subclass
* - false, if pagination needs to be disabled.
*
* @throws InvalidParamException
*/
public function setPagination($value)
{
if (is_array($value) && !isset($value['pageSizeLimit'])) {
$value['pageSizeLimit'] = [1, 100];
}
parent::setPagination($value);
}
示例2: actionLeader
public function actionLeader()
{
$dataProvider = Null;
$searchModel = new OrderSearch();
$totalbales = 0;
$query = new Query();
$dataProvider = new ActivedataProvider(['query' => Order::find(), 'pagination' => ['pageSize' => 20]]);
$totalProvider = new ActiveDataProvider(['query' => Order::find()]);
$totalProvider->setPagination(False);
$models = $totalProvider->getModels();
foreach ($models as $item) {
$totalbales += $item->number_bales;
}
return $this->render('leader', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'totalbales' => $totalbales]);
}
示例3: setPagination
/**
* @inheritdoc
*/
public function setPagination($value)
{
if (is_array($value)) {
$config = ['class' => Pagination::className()];
if ($this->id !== null) {
$config['pageParam'] = $this->id . '-page';
$config['pageSizeParam'] = $this->id . '-per-page';
}
parent::setPagination(Yii::createObject(array_merge($config, $value)));
} elseif ($value instanceof Pagination || $value === false) {
parent::setPagination($value);
} else {
throw new InvalidParamException('Only Pagination instance, configuration array or false is allowed.');
}
}
示例4: setPageSize
/**
* Sets page size
* @param \yii\data\ActiveDataProvider $dataProvider
*/
public static function setPageSize(\yii\data\ActiveDataProvider &$dataProvider, $pageSize)
{
$dataProvider->setPagination([$dataProvider->pagination->pageSizeParam => $pageSize]);
}
示例5: actionTestl
public function actionTestl()
{
echo "sss";
$dataProvider = new ActiveDataProvider(['query' => Appcomments::find()]);
//$dataProvider->keys;
//$dataProvider->models;
/*$dataProvider->setPagination(false);
$mymodel=$dataProvider->models;
foreach ($mymodel as $model){
echo $model['appid'];
}*/
$pagination = $dataProvider->getPagination();
var_dump($pagination->page);
$count = 0;
while ($categories = $dataProvider->models) {
/*foreach ($categories as $model) {
$model['appid']=0;
}*/
//echo $pagination->page=1+$count;
$count++;
$dataProvider->setPagination($count);
}
//$mymodel[4]['kind']="bbbbbb";
//$dataProvider->setModels($mymodel);
//var_dump($dataProvider->models[4]['kind']);
//echo $dataProvider->models;
}
示例6: searchFront
/**
* Creates data provider instance with search query applied
*
* @param array $params
* @param integer $category
* @param null|string $user
* @return ActiveDataProvider
* @internal param int $post_type
*/
public function searchFront($params, $category = null)
{
$query = PostModel::find();
if ($category) {
$query->join('left join', 'term_relationship', "term_relationship.post_id = post.id");
$query->andWhere(['term_relationship.term_id' => $category]);
}
$query->andWhere(['post.post_type' => 1]);
$dataProvider = new ActiveDataProvider(['query' => $query]);
$dataProvider->setSort(['attributes' => ArrayHelper::merge($dataProvider->sort->attributes, ['username' => ['asc' => ['username' => SORT_ASC], 'desc' => ['username' => SORT_DESC], 'label' => 'Author', 'value' => 'username']]), 'defaultOrder' => ['post_date' => SORT_DESC]]);
$dataProvider->setPagination(['pageSize' => 2]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
return $dataProvider;
}