Filter relation CGridView

I know this topic has been done to death, but all the searching and hacking away I do just leaves me more confused than ever. Is there a definitive guide to properly including a relation in a CGridView, and actually having both the filter (text field, NOT drop down list) AND sorting work properly?

Here is what I am trying, based on this topic:




/********************/

/* Highlights model */

/********************/

public $fullname;


//relation

'user' => array(self::BELONGS_TO,'UserInfo','username'),


//search() method

$criteria->compare('fullname',$this->fullname,true); //also tried $this->user->fullname

$criteria->with=array('user'); //tried with and without this line




/**************************/

/* CGridView (index view) */

/**************************/

array(

	'name' => 'user', //also tried username and fullname

	'filter' => CHtml::activeTextField($model, 'fullname'), 

	'value' => '$data->user->fullname',

),



No combination of any of these lines seems to work - the sorting is disabled and the filter does nothing when I type anything into it; no errors, no nothing. I always get tripped up by this issue. There must be a straightforward method to getting this to work…does anyone know how???

I used to do something like this to filter CGridView with relation.

In model:

// declare attribute


public $fullname;

// search procedure




$criteria->compare('user.fullname',$this->fullname,true);

$criteria->with = 'user';


// set sort options

$sort = new CSort;

$sort->attributes = array(

  'fullname'=>array(

     'asc'=>'user.fullname',

     'desc'=>'user.fullname DESC',

  ),

  ... (your other fields)

);			

	

return new CActiveDataProvider($this, array(

   'criteria'=>$criteria,

   'sort'=>$sort

));



// include field in rule




array('fullname', 'safe', 'on'=>'search')



In CGridView (view):




array(

   'name'=>'fullname',

   'value'=>'$data->user->fullname',

),



Hope this helps. :)

THANK YOU!!!!!!!!!!!!!!!!!!!! :-* :-* :-*