Yii Framework Forum: Value of 'itemView' in view file - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Value of 'itemView' in view file Rate Topic: -----

#1 User is offline   Blue Sapphire 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 27-February 10

Posted 07 May 2010 - 09:07 AM

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
0

#2 User is offline   Blue Sapphire 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 27-February 10

Posted 10 May 2010 - 03:18 AM

Any reply for my query ?
0

#3 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,013
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 10 May 2010 - 06:17 AM

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

#4 User is offline   Blue Sapphire 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 27-February 10

Posted 10 May 2010 - 07:41 AM

Kindly view following link:
http://www.yiiframew...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.

Quote

•$this: refers to the owner of this list view widget. For example, if the widget is in the view of a controller, then $this refers to the controller.


Can some one guide me in this regards

Thanks in advance
0

#5 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,013
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 10 May 2010 - 07:45 AM

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

#6 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,003
  • Joined: 30-October 09
  • Location:UK

Posted 11 May 2010 - 04:15 AM

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

#7 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,317
  • Joined: 12-October 09
  • Location:Croatia

Posted 11 May 2010 - 06:24 AM

GSTAR is right... the current implementation is that 'itemView' is a name of the view to be rendered
Find more about me.... btw. Do you know your WAN IP?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users