add two table with filter in GridView

I have two tables:

post [id, title, content, img, user_id]

user [id, username, email, password]

How can use filter user_id and username in CGridView?

I added username with filter username but I need add user_id with filter user_id too.

Post Model:

Public $username;

return array(

          'user' => array(self::BELONGS_TO, 'User', 'user_id'),


 public function search()


     $criteria=new CDbCriteria;







     return new CActiveDataProvider($this, array(




Post view:

<?php $this->widget('zii.widgets.grid.CGridView', array(











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






)); ?>

here help yourself

Thanks it’s help me.