I use CSqlDataProvider as the dataProvider of a CListView. When I click page 2, the entire webpage is refreshed, and I can see in the address bar like xxx/index.php/module/3?concept_id_page=2. This is obviously not an ajax mode.
For sure that I want the pagination is in the ajax mode, rather than refreshing the entire webpage.
Can someone please tell me what the problem is?
btw, I read class reference, to say, we can choose the pagination mode as normal (refresh entire webpage) or ajax, but I still cannot figure out how to choose the mode. And I am not sure whether I can specify the ajax mode to solve my problem.
Below is my code:
In controller:
$count=Yii::app()->db->createCommand($sql)->queryScalar();
$dataProvider=new CSqlDataProvider($sql, array(
'totalItemCount'=>$count,
'id'=>'concept_id',
'keyField'=>'concept_id',
'sort'=>array(
'attributes'=>array(
'create_at',
),
),
'pagination'=>array(
'pageSize'=>5,
),
));
view:
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$this->getConcepts($model->module_id),
'itemView'=>'_item',
'summaryText'=>'',
)); ?>
_item.php
<p><span class="title"><?php echo $data['name']?></span></p>
This is the first time that I use CSqlDataProvider. That is because I want to write sql to join 3 tables (MANY TO MANY TO MANY). Besides the problem mentioned above, the other question is how I can access the attribute like $data->name rather than $data[‘name’].