2013-03-07 58 views
2
<table border="1"> 
    <tr> 
     <th width="35">S.No.</th> 
     <th align="left">Club Member</th> 
     <th width="155">Schedule</th> 
     <th width="155">Point</th> 
    </tr> 
     <?php $this->widget('zii.widgets.CListView', array(
      'dataProvider'=>$dataProvider, 
      'itemView'=>'_reportSchedule', 
     )); ?> 
</table> 

我怎樣才能得到序列號像1,2,3等?CListView - 添加序列號

+0

你的意思是「我怎樣才能得到」? – 2013-03-07 08:14:14

+0

如何顯示序列號? – yajay 2013-03-07 08:16:46

回答

3

在查看文件 「_reportSchedule」 使用:

<?php echo ++$index;?> 
+1

謝謝。它的工作原理,但從0開始,所以我用戶<?php echo ++ $ index; ?> – yajay 2013-03-07 08:19:39

+0

你的歡迎..我忘了增加運營商。 – 2013-03-07 08:22:24

0

在你_reportSchedule.php局部視圖,你可以使用echo出來:

echo $data->serial_number; 

這假定SERIAL_NUMBER是您使用的任何模型的屬性。作爲mnetioned通過Sudhanshu Saxena先生,如果你只是想索引(在設置項目的數量),使用方法:

echo $index 

這是一個從零開始的編號系統(第一條記錄爲0的指數)

0

只使用在查看文件「_reportSchedule」

$widget->dataProvider->getPagination()->currentPage * $widget->dataProvider->getPagination()->pageSize + $index + 1; 
0

$index指示開始0行的數量,是爲了顯示正確的數量上的所有頁面都需要進行計算:

$widget->dataProvider->getPagination()->currentPage * $widget->dataProvider->getPagination()->pageSize + $index + 1