Answer the question
In order to leave comments, you need to log in
Correct output through CGridView and the right data from CActiveDataProvider?
Hello everyone, I need advice on these two things.
1. CGridView.
I need to make not one line but 2 in the table that it forms, since there is a lot of data, I tried various perversions with js and Html and settled on this option.
array(
'headerHtmlOptions' => array(
'style' => 'display: none'
),
'filterHtmlOptions' => array(
'style' => 'display: none'
),
'htmlOptions' => array(
'style' => 'display: none'
),
'value' => array($this, 'gridPropertyData'),
),
public function gridPropertyData($data, $row){
return $this->renderPartial("//common/property_info", array("data" => $data), false);
}
</td></tr><tr>
$criteria->compare('city',$this->_city->name);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
Answer the question
In order to leave comments, you need to log in
1. Only by extending the class CGridView
and overriding the methodrenderTableRow()
2. See http://www.yiiframework.com/doc/guide/1.1/en/database.arr
$criteria=new CDbCriteria();
$criteria->with = ['city']; // название отношения, используется как префикс
$criteria->compare('city.name', $this->_city->name);
...
Model
$criteria->with = ['_city'];
$criteria->compare('_city.name', $this->_city->name);
Grid
array(
'name'=>'_city.name',
)
Question: the norms are displayed, but now how to fasten the search so that it works like the rest on Ajax and sorting, because only the Name is displayed in th, without links, can I screw it manually through the header or is there a way?
Sorting:
$dataProvider=new CActiveDataProvider('Model', array(
'Sort'=>array(
'defaultOrder'=>'t.id DESC',
'attributes'=>array(
'CityName'=>array(
'asc'=>'_city.name',
'desc'=>'_city.name DESC',
'label'=>'Город,
'default'=>'asc',
),
'*',
),
),
...
'sortableAttributes'=>array(
...
'CityName',
...
),
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question