holala
(Holala)
January 18, 2010, 11:55am
1
the CGridview all the data,I don’t want to show all the data ,i want show some data with condition,like survey_id = 1,how can i do that?
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'id',
'survey_id',
'name',
'name_en',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
qiang
(Qiang Xue)
January 18, 2010, 1:25pm
2
You should do this with the data provider, not grid view:
$dataProvider=new CActiveDataProvider('ModelClass', array(
'criteria'=>array(
'condition'=>'....'
),
));
jiania
(Jiania)
January 19, 2010, 2:31pm
4
by the way ,how to show some data with condition in relation model when use CGridview?
qiang
(Qiang Xue)
January 19, 2010, 5:10pm
5
That can be similarly done except that you also need to specify the ‘with’ option in the query criteria.
thyseus
(Thyseus)
January 29, 2010, 9:38pm
6
Does this also work with MANY_MANY relations?
$criteria = new CDbCriteria;
$criteria->with = array('categories') // categories is a MANY_MANY related model
$criteria->condition = array('categories = 54') // <-- want to display every ROW that has the category 54
is this possible to add some MANY_MANY intelligent logic to the CDbCriteria like this ? thank you !
lexand
(Dorogikh Alexander)
January 30, 2010, 12:50pm
7
Yesterday I asked about this on russian forum… but I didn’t heard any answers.
I solve this in… IMHO very ugly way.
I use some additional model attributes and handful of subqueries.
Currently I try to find more elegant solution
reykel
(Rhpalacios66)
December 13, 2015, 11:47pm
10
I think you should get a more extensive explanation. If still open to it please tell me