Numbering Clistview Results

Is there an easy way to number each record and label each with like 1, 2, 3 or better yet 1st, 2nd, or 3rd generated by ClistView. Here is my ClistView


$this->widget('zii.widgets.CListView', array(

                            'dataProvider'=>$dataProvider,

                            'itemView'=>'_view',

                            'emptyText'=>'There are no clients  waiting in line',

               

                            'summaryText'=>'There are {count} clients waiting in line',


                    ));

Dear Friend

We can do something like this.

index.php




<?php $this->widget('zii.widgets.CListView', array(

	'dataProvider'=>$dataProvider,

	'itemView'=>'_view',

	'viewData'=>array("dataProvider"=>$dataProvider),

)); ?>



_view.php




<?php

 $itemNumber=($dataProvider->pagination->pageSize*$dataProvider->pagination->currentPage)+array_search($data,$dataProvider->getData())+1;

?>

div class="view">

   

	<?php echo CHtml::encode($itemNumber); ?>

	<br />


<!-- below all the routine attributes -->


	<b><?php echo CHtml::encode($data->getAttributeLabel('id')); ?>:</b>

	<?php echo CHtml::link(CHtml::encode($data->id), array('view', 'id'=>$data->id)); ?>

	<br />


	<b><?php echo CHtml::encode($data->getAttributeLabel('name')); ?>:</b>

	<?php echo CHtml::encode($data->name); ?>

	<br />


	<b><?php echo CHtml::encode($data->getAttributeLabel('mark')); ?>:</b>

	<?php echo CHtml::encode($data->mark); ?>

	<br />


	<b><?php echo CHtml::encode($data->getAttributeLabel('rank')); ?>:</b>

	<?php echo CHtml::encode($data->rank); ?>

	<br />




</div>



We can also calculate itemNumber in the following way.




($dataProvider->pagination->pageSize*$dataProvider->pagination->currentPage)+$index+1;

//$index is provided by the dataprovider for current item.



Regards.

Yesss! Thanks!