Monday, March 5, 2012

Add paging index in your CListView

If you are using CListView to populate your data you can customize your view to show the automatic number of your CListView..

you can just add $index variable to your _view in CListView


<div class="view" >
 <i><b><?php echo CHtml::encode($data->getAttributeLabel('Project title')); ?>:</b></i>
 <span class="info">
 <?php echo $index+1;?>//this is the variable in CListView
 </span>
 <h3><?php echo CHtml::link(CHtml::encode($data->title), array('view', 'id'=>$data->project_id)); ?></h3>

In your index file in your view you can see like this :


<h1>Projects</h1>

<?php $this->widget('zii.widgets.CListView', array(
 'dataProvider'=>$dataProvider,
 'itemView'=>'_view',
)); ?>

2 comments:

  1. This is really too useful and has more ideas from your blog. Keep sharing more blog like this, thank you. ................................Please contact us for Oracle Fusion SCM Training details

    ReplyDelete
  2. This is just the kind of information that I had been looking for a long time. Thank you very much for posting this blog its very nice.

    SAP S4 HANA Training in Dallas

    SAP S4 HANA Training in Dallas

    ReplyDelete