Value of 'itemView' in view file

Iam using CListView in a View. What will be the value of ‘itemView’, if I want to show records on same view. Iam trying to use values ‘$this’ and ‘$index’ but these are giving errors. My view code is as follows:




<?php

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

                   'dataProvider' => $dataProvider,

                   'itemView' => $this

    ));


?>


<div class="view">

        <?php echo $data->id ?><br/>

</div>




Can some one guide me where Iam doing wrong and how to rectify it.

Thanks in advance

Any reply for my query ?

If i understand you well: You can’t use the same view your grid is defined in, to be used as itemView. Per definition that is a separate view.

Kindly view following link:

http://www.yiiframework.com/doc/api/CListView#itemView-detail

May be Iam not understanding it properly. As fas as my understanding is concerned, there ‘$this’ is used. Iam pasting the lines from documentation.

Can some one guide me in this regards

Thanks in advance

You need to create another view file for your items (e.g. myitemview.php) and configure that:


<?php

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

                   'dataProvider' => $dataProvider,

                   'itemView' => 'myitemview',

    ));

?>



In that file you thencan use $this, etc. as described.

I had this difficulty too. Ideally I want to create the CListView and the corresponding view markup in the same file (as illustrated in the first post). Unfortunately I don’t think that is possible and we need to have a separate file for the view markup.

GSTAR is right… the current implementation is that ‘itemView’ is a name of the view to be rendered