34k+
News
Guide
API
Wiki
Forum
Community
Places
Members
Hall of Fame
Badges
More
Learn
Books
Resources
Develop
Download Yii
Extensions
Report an Issue
Report a Security Issue
Contribute to Yii
Donate
About
Release Cycle
License
Team
Official Logos and Design
Login
Searching and sorting by related model in CGridView
Comparing
#1
with
#2
Revision #2 was created by
Maciej Liżewski
on Dec 1, 2011, 6:51:53 PM.
How to allow searching and sorting with respect to related active record column in CGridView
« Previous (#1)
Next (#3) »
Content
[...]
```php
$criteria = new CDbCriteria;
$criteria->with = array( 'author' );
...
$criteria->compare( 'author.
user
name', $this->author_search, true );
...
```
[...]
'attributes'=>array(
'author_search'=>array(
'asc'=>'author.
user
name', 'desc'=>'author.
user
name DESC',
),
'*',
[...]
'title',
'post_time',
array( 'name'=>'author_search', 'value'=>'$data->author->
user
name' ),
array(
'class'=>'CButtonColumn',
),
),
));
[...]