2013-03-07 4 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

"어떻게받을 수 있습니까?" –

+0

일련 번호를 표시하는 방법은 무엇입니까? – yajay

답변

3

"_reportSchedule"이 사용

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

감사합니다. 그것은 작동하지만 0부터 시작하므로 i user yajay

+0

환영합니다. 나는 연산자를 증가시키는 것을 잊어 버렸다. –

0

당신의 _reportSchedule.php 부분보기에서는 사용하여 밖으로 반향 수 있습니다

echo $data->serial_number; 

이것은 SERIAL_NUMBER이를 것으로 가정 당신이 사용하고있는 모델의 속성. Sudhanshu Saxena는에 의해 mnetioned으로 단순히 인덱스 (세트에있는 항목의 수를) 원하는 경우, 사용

echo $index 

가 0 기반의 번호 체계이다

(첫 번째 레코드는 0의 인덱스가) 모든 페이지가 계산을 필요에
0

은 정확한 수를 표시하려면보기 파일 "_reportSchedule"

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

$index0에서 시작하는 라인의 수를 나타냅니다에 사용

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