2012-05-08 31 views
0

使用Yii時,我在ajaxUpdate中看到了CGridView的分頁。這非常有用。現在,我需要將它合併到CListView中。但我不知道爲ajaxUpdate設置了什麼。如何Yii啓用CListView的頁面上的ajaxLink?

這裏是controller code

$dataProvider = new CActiveDataProvider('Match',array(
    'criteria'=>array(
     'condition' => 'group_id = :groupId', 
     'params' => array(':groupId'=>$groupId), 
     'order'=>'date DESC', 
    ), 
    'pagination'=>array(
     'pageSize'=>3, 
    ), 
)); 
$this->renderPartial($view = "_matchsOfGroup", array(
    'dataProvider' => $dataProvider 
)); 

這是我的view code_matchsOfGroup

<div class="lobbyMain"> 
    <?php 
     $this->widget('zii.widgets.CListView', array(
      'dataProvider'=>$dataProvider, 
      'ajaxUpdate'=>true, 
      'template'=>'{items}{pager}', 
      'itemView'=>'_match', 
      'pager'=>array(
       'header'  => '', 
       'maxButtonCount'=> '3',      
      ),    
     )); 
    ?> 
</div> 

_match局部

<table> 
    <thead> 
    <th>date</th> 
    <th>Player</th> 
    <th>stack</th> 
    </thead> 
    <?php foreach($data->matchResults as $result) : ?> 
     <tr> 
      <td><?php echo $data->date; ?></td> 
      <td><?php echo $result->user->username; ?></td> 
      <td><?php echo $result->total_stack; ?></td> 
     </tr> 
    <?php endforeach; ?> 
</table> 

如何配置 '尋呼機'=>數組( )在zii.widgets.CListView使用AJAX鏈接請求

回答

0
$this->renderPartial($view = "_matchsOfGroup", array(
'dataProvider' => $dataProvider)); 

變化

$this->renderPartial($view = "_matchsOfGroup", array(
'dataProvider' => $dataProvider),false, true); 
+0

哦,它仍然無法正常工作。因爲配置'pager'=> array(...)會生成gereral鏈接'next'。我希望它可以生成'ajaxLinks'來發送ajax請求。 – Davuz

+0

我之前編寫的代碼讓Yii生成了啓用ajax分頁所需的js代碼。林不知道,但似乎CListViee默認使用ajax。查看與目標控制器生成的html - 檢查是否存在鏈接到尋呼機鏈接的某些js代碼。對不起我的英語不好 :) – temni