我是yii2的新手要添加分页它显示的id列表只有botstrap和链接没有显示什么是问题任何人解释我这是gridview
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'id' => 'grid',
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'user_fname',
'user_id',
'user_lname',
'user_mobile',
['class' => 'yii\grid\ActionColumn'],
[ 'class' => 'yii\grid\CheckboxColumn'],
],
]);
?>
<?php
echo yii\widgets\ListView::widget([
'dataProvider' => $dataProvider,
'View' => 'usermaster',
'layout' => "{pager}\n{items}\n{pager}",
]);
&GT?;
这是搜索控制器,我已添加了pagignation类
public function search($params)
{
$query = UsermasterModel::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => 10,
],
'sort' => [
'defaultOrder' => [
'user_fname' => SORT_DESC,
'user_fname' => SORT_ASC,
]
],
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'user_id' => $this->user_id,
]);
$query->andFilterWhere(['like', 'user_fname', $this->user_fname])
->andFilterWhere(['like', 'user_lname', $this->user_lname])
->andFilterWhere(['like', 'user_mobile', $this->user_mobile]);
return $dataProvider;
}
}