Add Condition On Relation In Grid View

How can I add a condition for a relation to the query for grid view?

I can see that by default Yii creates a second query for related data to display.

This does not work for me at all, I want an inner join.

I have a related table which includes a ‘language_id’ column (composite primary key >> id, language_id). I wish to filter all results based on a selected language_id.

What I see now are all results with data from my related table apparently showing the first rows it encounters (english).

What have you tried so far?

i have used this king of queries with belongs to relations :) :)

here is some sample code…


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

	'id'=>'user-transection-grid',

	'dataProvider'=>$model->search(),

	//'filter'=>$model,

    

                 'template' => '{items}{pager}',

                 'pager'=>array(

                                         'header'=>'',

                                         'htmlOptions'=>array('class'=>'pagination pull-right'),

                                      ),

                 'itemsCssClass' => 'table table-bordered  no-filter',

    

[code]

               'columns'=&gt;array(


	


                            array(


                                        'name'=&gt;'ut_fk_b_id',


                                          'header'=&gt;'Name',	


                                        'value'=&gt;'ucwords(&#036;data-&gt;utFkB-&gt;bFkUd-&gt;ud_first_name.&#092;' &#092;'.&#036;data-&gt;utFkB-&gt;bFkUd-&gt;ud_last_name)',


                                         'filter' =&gt; false,


                                        'sortable'=&gt;false,


                                ),


                   


                                





                            array(


                                   


                                        'name'=&gt;'ut_date',


                                         'header'=&gt;'Services Taken',


                                        'value'=&gt;'UserTransectionController::service_id(&#036;data-&gt;utFkB-&gt;b_id)',


                                         //'filter' =&gt; false,		


                                         'sortable'=&gt;false,


                                         


                                ),


                 


                            array(      


                                         'name'=&gt;'ut_fk_b_id',


                                        'header'=&gt;'Subscription',


                                        'value'=&gt;'&#036;data-&gt;utFkB-&gt;bFkWp-&gt;wp_name',


                                         'filter' =&gt; false,		


                                         'sortable'=&gt;false,


                                        


                                ),

// array(

// ‘name’=>‘ut_updated_date’,

// ‘header’=>‘Plan’,

// ‘value’=>’$data->utFkB->bFkSp->sp_name’,

// //‘filter’ => false,

// //‘sortable’=>false,

//

// ),

                                array(


			'filter' =&gt; false,


                                'sortable'=&gt;false,


	      'name'=&gt;'ut_is_enabled',


		   'header'=&gt;'Status',


		   'type'=&gt;'raw',


		   


		   'value'=&gt; function (&#036;data){ 


		        if(&#036;data-&gt;ut_is_enabled==1)


		    


		     return &quot;&lt;a href='javascript:void(0)' &gt;&lt;img src='&quot;.Yii::app()-&gt;request-&gt;baseUrl.&quot;/images/active.png' &gt;&lt;/a&gt; &quot;;


				else


				 return &quot;&lt;a href='javascript:void(0)' &gt;&lt;img src='&quot;.Yii::app()-&gt;request-&gt;baseUrl.&quot;/images/inactive.png' &gt;&lt;/a&gt; &quot;;


		   }


	


	


	    ),


                   


	//end here

// array(

// ‘header’=>‘Actions’,

// ‘class’ => ‘CButtonColumn’,

// ‘template’ => ’ {update} ',

// ‘buttons’ => array(

// ‘update’ => array(

// ‘label’ => ‘Edit’,

// ‘url’ =>’$this->grid->controller->createUrl(“update”,array(“id”=>$data->primaryKey, ))’,

// ‘imageUrl’ => false,

// ‘options’ => array(‘class’ => 'btn btn-warning '),

// ),

//

//

// ),

//

// ),

),

)); ?>[/code]

here is query with belongs to relation


'value'=>'$data->utFkB->bFkWp->wp_name';

thanks… : :-[