CGridView Search in a relational field

I have a display grid with orders. All orders have a username attached so it makes a lot of sense to search within a relational field (searching orders by username). Problem is, I can’t get the grid to perform a search on relational fields. Here’s my code…:

public function relations () {

	return array ( 


		'user' => array ( 








public function search () {

	$criteria = new CDbCriteria ();

	$criteria->order = 'date_added DESC';

	$criteria->compare ( 'transaction_id', $this->transaction_id, true );

	$criteria->compare ( 'status', $this->status, true );


        //        'troo' is just part of an existing username I have

	$criteria->compare ( 'user.username', 'troo', true );


	return new CActiveDataProvider ( 'Order', array ( 


		'criteria' => $criteria 

	) );


Running this code throws an error like: CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘user.username’ in ‘where clause’.

So how does one search through a relational field?

Try to add: