Yii Framework Forum: Question About Cactivedataprovider - Yii Framework Forum

Jump to content

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

Question About Cactivedataprovider Rate Topic: -----

#1 User is offline   mohsen davoodi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 20-August 12

Posted 13 October 2012 - 02:42 AM

Hello

In controller I use CActiveDataProvider for fetching my data from database.
In view I use zii.widget.CListView for showing the data but I want to put each 3 results in a div.
Please help me,
0

#2 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,165
  • Joined: 05-January 12
  • Location:Morocco

Posted 13 October 2012 - 04:37 AM

I guess you can apply some styling (specifying width + floating the div).

You can also specify which CSS file / CSS classes you want to use in your ListView.

http://www.yiiframew...i/1.1/CListView
1

#3 User is offline   mohsen davoodi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 20-August 12

Posted 13 October 2012 - 09:17 AM

I didn't find answer my question in that page. I want this position

<div class='row'>
   // data item 1
   // data item 2
  // data item 3
</div>
<div class='row'>
   // data item 4
   // data item 5
  // data item 6
</div>
.
.
. until end

0

#4 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,165
  • Joined: 05-January 12
  • Location:Morocco

Posted 13 October 2012 - 10:01 AM

The idea is to change the styling of the container div, in order that it has like 30% width and that it floats left, and 5% right-margin.

Otherwise, you can just use this extension that renders the listview items into a table of as many columns as you want: http://www.yiiframew...columnlistview/
1

#5 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,045
  • Joined: 16-February 11
  • Location:Japan

Posted 14 October 2012 - 12:35 AM

You can use $index variable in your partial view for the CListView.
<?php if ($index % 3 === 0): ?>
<div class="row">
<?php endif; ?>
... rendering item ...
<?php if ($index % 3 === 2 || $index === $widget->dataProvider->itemCount - 1): ?>
</div>
<?php endif; ?>


http://www.yiiframew...itemView-detail
2

#6 User is offline   mohsen davoodi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 20-August 12

Posted 14 October 2012 - 12:32 PM

the problem is solved;
thank you very much for helping me :)
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