Yii CListView-添加序列号 没有。 俱乐部会员 日程 指向

Yii CListView-添加序列号 没有。 俱乐部会员 日程 指向,yii,Yii,如何获取序列号(如1、2、3等)?在视图文件“\u reportSchedule”中使用以下命令: <table border="1"> <tr> <th width="35">S.No.</th> <th align="left">Club Member</th> <th width="155">Schedule</th> &l

如何获取序列号(如1、2、3等)?

在视图文件“\u reportSchedule”中使用以下命令:

<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>

在您的\u reportSchedule.php局部视图中,您可以使用以下命令将其回显出来:

<?php echo ++$index;?> 
这假设序列号是您使用的任何型号的属性。如Sudhanshu-Saxena所述,如果您只是想要索引(集合中项目的编号),请使用:

这是一个基于零的编号系统(第一条记录的索引为0)

只需在视图文件“\u reportSchedule”中使用


$index
表示从
0
开始的行号,用于在需要进行计算的所有页面上显示正确的行号:

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

你说“我怎么能得到”是什么意思?怎么显示序列号?谢谢。它可以工作,但从0开始,所以我需要一个用户
echo $index
$widget->dataProvider->getPagination()->currentPage * $widget->dataProvider->getPagination()->pageSize + $index + 1;
$widget->dataProvider->getPagination()->currentPage * $widget->dataProvider->getPagination()->pageSize + $index + 1