dubby
(Damien)
August 15, 2012, 7:14am
1
Hi all,
I am using CListView to render a view of items but by default this will add two divs to the HTML as follows:
<div id="yw0" class="list-view">
<div class="items">
I have found that I can add additional elements if I please but can anyone tell me how I stop these two elements from being generated?
alirz23
(Ali Raza)
August 15, 2012, 7:44am
2
hi you can remove you CListView and use this instead
<?php
$data = $dataProvider->getData();
foreach($data as $i => $item)
Yii::app()->controller->renderPartial('_view',
array('index' => $i, 'data' => $item, 'widget' => $this));
?>
will give you exact same thing but without the additional html
yiqing95
(Yiqing 95)
August 15, 2012, 7:49am
3
when using CListView/CGridView you can manually give it a "id".
and the "items" css can be anything you want but the div structure should better as it is .itemsCssClass
if you truly want modify the div structure you may have to extends it
dubby
(Damien)
August 15, 2012, 9:41am
4
OK, thanks for the responses.
I tried alirz23’s method but this leaves the view without any pagination which I require.
dubby
(Damien)
August 17, 2012, 7:18am
5
Does anyone else have anything to add?
Edit: Nevermind. I concede that it can’t be done without extending.
mdomba
(Maurizio Domba Cerin)
August 17, 2012, 7:37am
6
Note that if you remove those DIVs the sorting/pagination will not work with ajax calls as they use those DIVs to dynamically replace the content of the div to update the data (new page or sorting order)
dubby
(Damien)
August 17, 2012, 7:39am
7
OK. Thanks for this. I do want to keep the pagination.